Skip to main content

media_pp\core/
color.rs

1//! A plain RGB color value, shared by anything in this crate that needs
2//! one — compositor backgrounds, layer/text colors, and so on. Kept in
3//! `core` rather than under a specific element's module because nothing
4//! about it is pipeline- or backend-specific.
5
6/// An opaque RGB color (no alpha — compositor output is always opaque;
7/// per-layer translucency is a separate `opacity` field, not per-pixel
8/// alpha here).
9#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10pub struct Color {
11    pub red: u8,
12    pub green: u8,
13    pub blue: u8,
14}
15
16impl Color {
17    pub const BLACK: Self = Self::new(0, 0, 0);
18    pub const WHITE: Self = Self::new(255, 255, 255);
19
20    pub const fn new(red: u8, green: u8, blue: u8) -> Self {
21        Self { red, green, blue }
22    }
23}