rgb 0.8.53

`struct RGB/RGBA/etc.` for sharing pixels between crates + convenience methods for color manipulation. Allows no-copy high-level interoperability. Also adds common convenience methods and implements standard Rust traits to make `RGB`/`RGBA` pixels and slices first-class Rust objects.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
fn main() {
    use rgb::prelude::*;
    use rgb::Rgb;

    let px = Rgb {
        r: 255_u8,
        g: 0,
        b: 100,
    };
    #[cfg(feature = "bytemuck")]
    assert_eq!(rgb::bytemuck::cast_slice::<_, u8>(&[px])[0], 255);

    let px = Rgb::<u8>::new(255, 0, 255);
    let inverted: Rgb<u8> = px.map(|ch| 255 - ch);

    println!("{inverted}"); // rgb(0,255,0)
}