Conrod: Re-factor the `color` module

Created on 16 Jul 2017  路  3Comments  路  Source: PistonDevelopers/conrod

The current enum Color type is copied from the days where Conrod used elmesque (a functional, elm-inspired rust graphics library). These days it really does not make sense for Color to be an enum.

I think we should change the Color, Rgba and Hsla types to this:

pub struct Rgba(pub [f32; 4]);
pub struct Hsla(pub [f32; 4]);
pub type Color = Rgba;

Most helpful comment

If Rgba is actually sRGB format, perhaps it's clearer if it's named Srgba.

Edit: If not, the API docs should include that it's Linear

All 3 comments

If Rgba is actually sRGB format, perhaps it's clearer if it's named Srgba.

Edit: If not, the API docs should include that it's Linear

It seems like Rgba and Hsla structs are in the code. Is there anything else to be done?

Also, why have a type alias for Color? Why not just force users to choose either Rgba or Hsla, since they are both already in the color module in the first place?

Just an update of where I'm at on this - If I were to revisit this today, I'd likely remove hsl support, only provide a minimal Srgba type and then refer users to the palette crate if they would like to work with other colour spaces.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gkbrk picture gkbrk  路  3Comments

SuperCuber picture SuperCuber  路  4Comments

mitchmindtree picture mitchmindtree  路  4Comments

alanpoon picture alanpoon  路  4Comments

zengsai picture zengsai  路  10Comments