Skip to main content

ColorMatrix

Struct ColorMatrix 

Source
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

Source

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.

Source

pub fn width(&self) -> usize

Width in modules.

Source

pub fn height(&self) -> usize

Height in modules.

Source

pub fn get(&self, x: usize, y: usize) -> u8

Read a cell’s palette index (0..=7).

Source

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.

Source

pub fn palette(&self) -> &[Rgb8; 8]

Borrow the 8-entry RGB palette.

Source

pub fn cell_color(&self, x: usize, y: usize) -> Rgb8

Resolve a cell to its RGB colour.

Trait Implementations§

Source§

impl Clone for ColorMatrix

Source§

fn clone(&self) -> ColorMatrix

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ColorMatrix

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more