[][src]Struct texel_types::Sprite

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

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

impl Sprite[src]

pub fn frame_index(&self) -> usize[src]

Current frame index for this sprite

pub fn frame_count(&self) -> usize[src]

Sprite frame count

pub fn new_frame(&mut self)[src]

Creates a new frame copying contents of current frame

pub fn delete_frame(&mut self) -> bool[src]

Deletes current frame

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

Applies given frame change according to the which argument

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

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

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

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

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

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

Iterator for list of Texel for all frames in the sprite

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

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

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

Iterator over current frame's list of Texel

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

Mutable iterator over current frame's list of Texel

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

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

pub fn from_texels(texels: Texels) -> Sprite[src]

Creates a sprite from list of texels, single frame

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

Fills entire frame with color according to the ColorMode

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

Fills entire frame with given SymbolStyle

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

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

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

Applies texels starting at given pos Position2D

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

Applies color according to ColorMode in the given Bounds area

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

Applies a single style for the given Bounds area

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

Removes texels in given Bounds area

pub fn is_empty(&self) -> bool[src]

Empty check, true if all frames empty

Trait Implementations

impl Clone for Sprite[src]

impl Debug for Sprite[src]

impl Default for Sprite[src]

impl Eq for Sprite[src]

impl From<SpriteV1> for Sprite[src]

impl IntoIterator for Sprite[src]

type Item = Texel

The type of the elements being iterated over.

type IntoIter = IntoIter<Self::Item>

Which kind of iterator are we turning this into?

impl PartialEq<Sprite> for Sprite[src]

impl StructuralEq for Sprite[src]

impl StructuralPartialEq for Sprite[src]

Auto Trait Implementations

impl RefUnwindSafe for Sprite

impl Send for Sprite

impl Sync for Sprite

impl Unpin for Sprite

impl UnwindSafe for Sprite

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.