Color::from_hex(u32) -> Color ignores alpha
I stumbled upon this recently, lost in confusion coming from debugging colors when alpha was not being what was expected... https://docs.rs/macroquad/latest/src/macroquad/color.rs.html#95-99
I am guessing alpha should not be ignored here, unless there is a reason to do so (in which case the function should somehow make it explicit) ?
Fair point, feel free to make a PR!
Tho I am not quite sure how it should work, 0x3CA7D5 should be a light blue, but with alpha being 0x00 it would a little harder to use from_hex for opaque objects? I do not know really
I thought a bit about this, and to avoid update problems, I'd like to:
- implement
std::convert::From<u32> for Color(with alpha) - modify from_hex to make obvious alpha is always 1... Not sure how though.
Anyway 0x3CA7D5 is 24 bits, so not u32. Not sure how that works...
I ll try to take some time in the following weeks to explore what type conversion is possible safely in rust...
Looking at SDL, there is a whole structure dedicated to this kind of conversions: https://wiki.libsdl.org/SDL2/SDL_PixelFormat
Not sure what to make of it in our case here... I guess from_hex is just too generic/confusing for me...