citro3d/color.rs
1//! Color manipulation module.
2
3/// RGB color in linear space ([0, 1]).
4#[derive(Debug, Default, Clone, Copy)]
5pub struct Color {
6 pub r: f32,
7 pub g: f32,
8 pub b: f32,
9}
10
11impl Color {
12 pub fn new(r: f32, g: f32, b: f32) -> Self {
13 Self { r, g, b }
14 }
15
16 /// Splits the color into RGB ordered parts.
17 pub fn to_parts_rgb(self) -> [f32; 3] {
18 [self.r, self.g, self.b]
19 }
20
21 /// Splits the color into BGR ordered parts.
22 pub fn to_parts_bgr(self) -> [f32; 3] {
23 [self.b, self.g, self.r]
24 }
25}