Skip to main content

Painted

Struct Painted 

Source
#[non_exhaustive]
pub struct Painted { /* private fields */ }
Expand description

A picture a skin paints at run time (ADR-0078). Its fields keep their sizes, so they are read and written through methods; the ones that write move its revision.

Implementations§

Source§

impl Painted

Source

pub fn rgba(width: u16, height: u16) -> Self

An RGBA picture width × height, every pixel clear.

Source

pub fn indexed(width: u16, height: u16, palette: &[Rgb]) -> Self

An indexed picture width × height, every pixel index 0, its palette the first PALETTE_LEN colours of palette and black for the rest.

Source

pub fn one_bit(width: u16, height: u16) -> Self

A one-bit picture width × height, every pixel black, without a mask (every pixel drawn).

Source

pub fn with_mask(self) -> Self

The same one-bit picture with a mask, every pixel drawn; any other picture as it is.

Source

pub const fn size(&self) -> (u16, u16)

Its width and height in pixels.

Source

pub const fn kind(&self) -> PaintedKind

What its bytes are.

Source

pub const fn stride(&self) -> usize

Bytes per row of its pixels (and mask).

Source

pub const fn revision(&self) -> u32

How many times its pixels, palette or mask were borrowed for writing, wrapping: a picture whose revision didn’t move since a frame is that frame’s.

Source

pub fn pixels(&self) -> &[u8] ⓘ

Its bytes, as its kind says.

Source

pub fn pixels_mut(&mut self) -> &mut [u8] ⓘ

Its bytes to write; moves the revision.

Source

pub fn palette(&self) -> &[Rgb]

An indexed picture’s PALETTE_LEN colours; none for another.

Source

pub fn palette_mut(&mut self) -> &mut [Rgb]

An indexed picture’s colours to write (none for another); moves the revision.

Source

pub fn mask(&self) -> Option<&[u8]>

A one-bit picture’s mask, a set bit drawn, if it has one.

Source

pub fn mask_mut(&mut self) -> Option<&mut [u8]>

The mask to write, if it has one; then moves the revision.

Source

pub fn rgba_at(&self, x: u16, y: u16) -> [u8; 4]

Pixel (x, y), which must lie in the picture, as RGBA8: an indexed one’s colour, opaque; a one-bit one white or black, clear where the mask leaves it out.

Source

pub fn rgba_into(&self, out: &mut Vec<u8>)

Writes the whole picture as RGBA8, row after row, into out (its old bytes gone): each pixel as rgba_at has it. What a painter that draws RGBA uploads.

Source

pub fn fingerprint(&self) -> u64

The FNV hash (shuyi_assets::fnv) of its size, kind, pixels, palette and mask, not its revision: what a snapshot shows of it.

Trait Implementations§

Source§

impl Clone for Painted

Source§

fn clone(&self) -> Painted

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 Painted

Its size, kind, revision and fingerprint: its pixels would bury a failed test’s message.

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Painted

Source§

impl PartialEq for Painted

Source§

fn eq(&self, other: &Painted) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Painted

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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.