# gpui: Add \`alpha\` method to \`Rgba\` \(\#52125\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/c899d5b590dc7b470c7edd480855d0076482045c)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: c899d5b590dc7b470c7edd480855d0076482045c

Requested commit: c899d5b590dc7b470c7edd480855d0076482045c

Commit: c899d5b590dc7b470c7edd480855d0076482045c

Tree: 581752207256de003b7eec6a4cc3da76d207e0f6

Author: Sebastian Kootz

Committer: GitHub

## Message

```
gpui: Add `alpha` method to `Rgba` (#52125)

## Context

GPUI API change only: 
  - added `.alpha(a: f32)` method to `RGBA`
  - added `.opacity(factor: f32)` method to `RGBA`
  - added documentation for both new methods
  - added test coverage for both methods
  
These implementations already exist for the `HSLA` struct and were
missing for `RGBA`.

> [!NOTE]
> In my opinion, a trait implementation could be beneficial here. Let me
know what you think about that idea before I end up making unwanted
changes.

## How to Review

Just added the new methods, including documentation and test coverage.

## Self-Review Checklist

<!-- Check before requesting review: -->
- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Added `gpui::Rgba::alpha` and `gpui::Rgba::opacity` methods for
setting and scaling a color's alpha channel, matching the existing
`gpui::Hsla` API

---------

Co-authored-by: dino <dinojoaocosta@gmail.com>
```

## Parents

- [a9e469198a6069425bc15200e059a27ef32723ad](https://git.cafe/gitcafe/zed/commit/a9e469198a6069425bc15200e059a27ef32723ad?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/c899d5b590dc7b470c7edd480855d0076482045c?format=markdown)
