-
Notifications
You must be signed in to change notification settings - Fork 94
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
adding const fn with_a8() to Color #525
Conversation
That discussion is about The code itself looks good. |
Sorry, poorly worded. What I meant: Right now Color simply holds an int. When piet would switch to a more complex data type (to support HDR for example) it could be challenging to keep the methods I am introducing here So I see two (potential) decisions:
|
98f46d6
to
5f63b75
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your effort!
Let's merge this and see how it goes.
similar to
with_alpha()
, which unfortunately can't currently beconst fn
due to floating point arithmetic's, I am suggesting to addconst fn with_a8()
.My personal use case for it: I have a palette of predefined colors (think Gnome Colors), which I use as the basis for other default colors definitions (which is why I need 'const' ).
Related: the discussion that Color probably won't be anything else than u32 so the
const
is unlikely to become a problem in the future.With the same thought,
as_rgba_u32()
can then also converted to be const.I could also add analogous methods
with_r8()
,with_g8()
andwith_b8()
to the PR for completeness sake, if the idea is approved.