Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Allow creating Colors in a const context. #135

Merged
merged 4 commits into from
Dec 10, 2024

Conversation

jeffreyrosenbluth
Copy link
Contributor

Added a const function to create Color types and used it to create a module for W3C color names

@jeffreyrosenbluth
Copy link
Contributor Author

Fixes #77

@RazrFalcon
Copy link
Collaborator

I'm sorry, but this is way out of scope.
You can keep from_unchecked_rgba, but that's about it.

@jeffreyrosenbluth
Copy link
Contributor Author

Thats not a problem. from_unchecked_rgba is all I should really need. I deleted the rest.

@waywardmonkeys
Copy link
Collaborator

@jeffreyrosenbluth We (Linebender) also have a new color crate, https://github.com/linebender/color/... it has the named colors and more and we'll be releasing a 0.2.0 release o fit soon as we're integrating it now with Peniko and Vello. You might give it a look as well. I'd love to see us get a couple of additional crates that use color to do things like what you're doing in some of your other repos. Feel free to drop by our Zulip in the color channel!

@jeffreyrosenbluth
Copy link
Contributor Author

@waywardmonkeys Your color crate looks very nice. How does it differ from the palette crate?

/// All values must be in 0..=1 range.
pub const unsafe fn from_unchecked_rgba(r: f32, g: f32, b: f32, a: f32) -> Self {
Color {
r: NormalizedF32::new_unchecked(r),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, this could use a safety comment. In practise, the safety comment is the "unit" safety comment that preconditions are guaranteed by caller.

src/color.rs Outdated Show resolved Hide resolved
@DJMcNab DJMcNab changed the title color names Allow creating Colors in a const context. Dec 9, 2024
yes that's a better name

Co-authored-by: Daniel McNab <[email protected]>
@DJMcNab DJMcNab merged commit fdac4c2 into linebender:main Dec 10, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants