Struct texel_types::Sprite

source ·
pub struct Sprite {
    pub frames: Vec<Texels>,
    pub index: usize,
    pub id: Option<u32>,
    pub labels: HashMap<String, String>,
}
Expand description

Sprite represents a 2D ASCII art picture with frame animation

Fields§

§frames: Vec<Texels>

List of Frame data consisting of texels

§index: usize

Current Frame Index

§id: Option<u32>

Optional ID number to identify sprite in a scene

§labels: HashMap<String, String>

Optional list of labels for grouping sprites in a scene, key value pair labels

Implementations§

source§

impl Sprite

source

pub fn frame_index(&self) -> usize

Current frame index for this sprite

source

pub fn frame_count(&self) -> usize

Sprite frame count

source

pub fn new_frame(&mut self)

Creates a new frame copying contents of current frame

source

pub fn delete_frame(&mut self) -> bool

Deletes current frame

source

pub fn apply_frame_change(&mut self, which: Which<usize>) -> usize

Applies given frame change according to the which argument

source

pub fn read_area(&self, area: Bounds) -> impl Iterator<Item = &Texel>

Gives a read-only iterator over Texels in given area of this Sprite

source

pub fn read_texel(&self, pos: Position2D) -> Option<&Texel>

source

pub fn copy_area(&self, area: Bounds) -> Texels

Copies an area of given frame in the area: Bounds as Vec

source

pub fn all_iter(&self) -> impl Iterator<Item = &Texel>

Iterator for list of Texel for all frames in the sprite

source

pub fn all_iter_mut(&mut self) -> impl Iterator<Item = &mut Texel>

Mutable iterator for list of Texel for all frames in the sprite

source

pub fn frame_iter(&self) -> impl Iterator<Item = &Texel>

Iterator over current frame’s list of Texel

source

pub fn frame_iter_mut(&mut self) -> impl Iterator<Item = &mut Texel>

Mutable iterator over current frame’s list of Texel

source

pub fn from_txt_file(abs_path: &Path) -> Result<Self, Error>

Creates a sprite from given text file with default styles and colors

source

pub fn from_texels(texels: Texels) -> Sprite

Creates a sprite from list of texels, single frame

source

pub fn fill_color(&mut self, cm: ColorMode, color: u8) -> bool

Fills entire frame with color according to the ColorMode

source

pub fn fill_style(&mut self, style: SymbolStyle) -> bool

Fills entire frame with given SymbolStyle

source

pub fn apply_symbol( &mut self, symbol: char, bg: u8, fg: u8, area: Bounds ) -> Bounds

Applies symbol with bg/fg color combination in given Bounds area

source

pub fn apply_texels(&mut self, texels: Texels, pos: Position2D) -> Bounds

Applies texels starting at given pos Position2D

source

pub fn apply_color(&mut self, cm: ColorMode, color: u8, area: Bounds) -> bool

Applies color according to ColorMode in the given Bounds area

source

pub fn apply_style(&mut self, style: SymbolStyle, area: Bounds) -> bool

Applies a single style for the given Bounds area

source

pub fn clear_symbol(&mut self, area: Bounds) -> Option<Bounds>

Removes texels in given Bounds area

source

pub fn is_empty(&self) -> bool

Empty check, true if all frames empty

Trait Implementations§

source§

impl Clone for Sprite

source§

fn clone(&self) -> Sprite

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Sprite

source§

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

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

impl Default for Sprite

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl From<SpriteV1> for Sprite

source§

fn from(old: SpriteV1) -> Self

Converts to this type from the input type.
source§

impl IntoIterator for Sprite

§

type Item = Texel

The type of the elements being iterated over.
§

type IntoIter = IntoIter<<Sprite as IntoIterator>::Item>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl PartialEq for Sprite

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Sprite

source§

impl StructuralPartialEq for Sprite

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> 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,

§

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>,

§

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>,

§

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.