Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add AlphaColor::with_alpha #67

Merged

Conversation

waywardmonkeys
Copy link
Collaborator

This is similar to OpaqueColor::with_alpha, but allows modifying the alpha channel on an AlphaColor.

This can be done via map, but this is const, so it can result in better code in scenarios like:

    let c = color::palette::css::GOLDENROD.with_alpha(0.5);

@waywardmonkeys waywardmonkeys added this to the 0.2.0 milestone Nov 25, 2024
This is similar to `OpaqueColor::with_alpha`, but allows modifying
the alpha channel on an `AlphaColor`.

This can be done via `map`, but this is `const`, so it can result
in better code in scenarios like:

```
    let c = color::palette::css::GOLDENROD.with_alpha(0.5);
```
@waywardmonkeys
Copy link
Collaborator Author

This grew out of making Vello use color and there were 2 places that were directly setting the alpha.

My initial port was using map to do the modification, but this feels like a more elegant way and allows it to be const, which map does not.

@waywardmonkeys waywardmonkeys added this pull request to the merge queue Nov 25, 2024
Merged via the queue into linebender:main with commit 388f33c Nov 25, 2024
15 checks passed
@waywardmonkeys waywardmonkeys deleted the alphacolor-with-alpha branch November 25, 2024 04:12
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants