Description
This is a Rust API design nitpick.
As of rerun 0.7.0
, rerun::components::ColorRGBA
publicly uses a u32
to store the color. This is an unnecessary complication, because u32
s have endianness which confuses the question of which color component ordering in memory is actually meant. (For example, on little-endian architectures — most computers today — the components are actually stored as what someone discussing image formats would call ABGR, not RGBA.) In my opinion, the representation should actually be either [u32; 4]
(with an explicitly documented meaning of each array index) or a struct
#[repr(C)]
struct ColorRGBA {
r: u8,
g: u8,
b: u8,
a: u8,
}
Either one of these nails down the memory representation unambiguously, and will be representation-compatible (i.e. transmutable) with someone else's RGBA color type when it's actually RGBA and not ABGR.
Another option is to make the existing u32
field private, so that the interpretation of it is entirely an implementation detail of rerun
.