pub struct ColorMatrix { /* private fields */ }Expand description
A 2D colour matrix: rows × columns cells where each cell
carries a palette index into an 8-entry [Rgb8; 8] colour table.
Cells with palette index 0 are treated as background (typically
white) by the renderer — no rect / pixel emitted.
The 8-colour palette is fixed at the symbology level (e.g. the
AIM Ultracode CMYWK palette is defined in
crate::symbology::ultracode::ULTRACODE_PALETTE) so the
palette field is included in the struct for the renderer’s
convenience.
Implementations§
Source§impl ColorMatrix
impl ColorMatrix
Sourcepub fn new(width: usize, height: usize, palette: [Rgb8; 8]) -> Self
pub fn new(width: usize, height: usize, palette: [Rgb8; 8]) -> Self
Allocate an all-background (palette index 0) matrix of the given dimensions, with the given colour palette.
Sourcepub fn set(&mut self, x: usize, y: usize, palette_idx: u8)
pub fn set(&mut self, x: usize, y: usize, palette_idx: u8)
Write a cell’s palette index. Caller is responsible for
passing a value in 0..=7; out-of-range values are masked
to 3 bits to keep the field invariant.
Sourcepub fn cell_color(&self, x: usize, y: usize) -> Rgb8
pub fn cell_color(&self, x: usize, y: usize) -> Rgb8
Resolve a cell to its RGB colour.
Trait Implementations§
Source§impl Clone for ColorMatrix
impl Clone for ColorMatrix
Source§fn clone(&self) -> ColorMatrix
fn clone(&self) -> ColorMatrix
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more