-
Notifications
You must be signed in to change notification settings - Fork 95
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
A simple color type #40
Comments
Pure bikeshed incoming. It's a little weird to bake alpha into the encoding, considering that HTML/CSS doesn't do that and opts for 6 nibble color codes (e.g If integer literals are convertible to a trait IntoColor {
fn rgb(Self) -> Color;
fn rgba(Self) -> Color;
fn hsv(Self) -> Color;
fn hsva(Self) -> Color;
fn cmyk(Self) -> Color;
} Then the trait could be implemented for both let cyan = 0x00ffff.rgb();
let magenta = (0.833, 1.0, 1.0).hsv();
let transparent_white = 0xffffff00.rgba();
let transparent_black = (0.0, 0.0, 0.0, 0.0).rgba(); And then for the |
Discussion branched from review of #39.
Use of a raw
u32
is problematic to represent color. We should have a simple color type.One model is
ColorF
from the direct2d crate, which wraps D2D_COLOR_F but has its own conversions. I think having aFrom
conversion fromu32
interpreted as rgba (note the ColorF conversion is from rgb) would be good. I'd also be open to a conversion from (u32, f32), interpreted as (rgb, a); this latter conversion would be the same as ColorF. And APIs that directly accept color (solid_brush
) is the main thing, should acceptimpl Into
so any of these variants can be used.I'll note that the concept of color is extremely deep water. There are questions of colorspace (sRGB vs other standard RGB color spaces vs the idea of "device color"), gamut, depth (including HDR), use of color for print (CMYK and other spaces that include spot color), other appearance measurements such as gloss, etc. I don't want to get into any of that right now. The new color type would be, as much as specified, an 8 bit sRGB value with separate alpha. I can imagine adding more complex color types later as optional extensions.
Bikeshedding regarding naming and other similar questions are welcome.
The text was updated successfully, but these errors were encountered: