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

Feature add: const from_rgb for all colors #718

Open
LuckyTurtleDev opened this issue Jan 17, 2023 · 1 comment
Open

Feature add: const from_rgb for all colors #718

LuckyTurtleDev opened this issue Jan 17, 2023 · 1 comment

Comments

@LuckyTurtleDev
Copy link

LuckyTurtleDev commented Jan 17, 2023

Currently it is very hard to convert colors at compile time.
If you know the type already you can do this conversion manual .
But if you do not know the type yet you can not simple create a Bgr888 and call .into(), because it is not const.
A solution for this would be to add a const from_rgb(r, g,b) -> Self or const new_rgb(r, g,b) -> Self function to each color type (including the grays). So you can simple enter your "normal" 8bit color and it would be converted at compile time. The function could be implementation by using the already existing, but not public const functions.
This would very useful for usage inside macros. Current macros version can only create GrayColor, BinaryColor or PixelColor, but not for all at the same time, because they have a different new functions and need a special solution for each of them.

@mastercaution
Copy link

I'm also missing such a function.
The function you linked with_rgb888 is actually exactly what you want ... but it's private and I wonder why.

Making it public would allow for convenient const conversion like that:

const MATERIAL_GREEN: Rgb565 = Rgb565::with_rgb888(76, 175, 80);

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

No branches or pull requests

2 participants