Fix alpha blending formula - #594
Merged
Merged
Conversation
DHowett
reviewed
Aug 12, 2025
| 0xfff0e100, // BrightCyan | ||
| 0xffffffff, // BrightWhite | ||
| pub const DEFAULT_THEME: [StraightRgba; INDEXED_COLORS_COUNT] = [ | ||
| StraightRgba::from_be(0x000000ff), // Black |
Member
There was a problem hiding this comment.
why from_be sometimes and from_le other times?
Member
Author
There was a problem hiding this comment.
Just whatever I felt like in any given situation. from_be is helpful because it allows you to copy/paste the literal as a CSS color code (which is also in big endian).
DHowett
reviewed
Aug 12, 2025
| DEFAULT_THEME[IndexedColor::BrightWhite as usize], | ||
| ], | ||
| contrast_colors: [const { Cell::new((0, 0)) }; CACHE_TABLE_SIZE], | ||
| contrast_colors: [const { Cell::new((StraightRgba::zero(), StraightRgba::zero())) }; |
Member
There was a problem hiding this comment.
would this be helped by deriving default or implementing it to return zero
Member
Author
There was a problem hiding this comment.
Unfortunately no, because traits cannot be const and the Rust maintainers have been bickering working on an implementation for const traits since at least 2020. 🥲
DHowett
approved these changes
Aug 12, 2025
Lou32Verbose
pushed a commit
to Lou32Verbose/edit
that referenced
this pull request
Jan 11, 2026
Since `srgb_to_linear` is non-linear we can't use it for premultiplied colors. Instead of unpremultiplying them, I changed the rest of the app to straight alpha and introduced types to ensure we don't mess it up.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since
srgb_to_linearis non-linear we can't use it for premultiplied colors.Instead of unpremultiplying them, I simply changed the rest of the app to use
straight alpha and introduced types to ensure we don't mess it up.