conrod icon indicating copy to clipboard operation
conrod copied to clipboard

Re-factor the `color` module

Open mitchmindtree opened this issue 8 years ago • 3 comments

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;

mitchmindtree avatar Jul 16 '17 11:07 mitchmindtree

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

LaylBongers avatar Jul 16 '17 12:07 LaylBongers

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?

Yam76 avatar Jan 28 '20 21:01 Yam76

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.

mitchmindtree avatar Feb 04 '20 14:02 mitchmindtree