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
impl Sprite
sourcepub fn frame_index(&self) -> usize
pub fn frame_index(&self) -> usize
Current frame index for this sprite
sourcepub fn frame_count(&self) -> usize
pub fn frame_count(&self) -> usize
Sprite frame count
sourcepub fn delete_frame(&mut self) -> bool
pub fn delete_frame(&mut self) -> bool
Deletes current frame
sourcepub fn apply_frame_change(&mut self, which: Which<usize>) -> usize
pub fn apply_frame_change(&mut self, which: Which<usize>) -> usize
Applies given frame change according to the which
argument
sourcepub fn read_area(&self, area: Bounds) -> impl Iterator<Item = &Texel>
pub fn read_area(&self, area: Bounds) -> impl Iterator<Item = &Texel>
Gives a read-only iterator over Texel
s in given area of this Sprite
pub fn read_texel(&self, pos: Position2D) -> Option<&Texel>
sourcepub fn copy_area(&self, area: Bounds) -> Texels
pub fn copy_area(&self, area: Bounds) -> Texels
Copies an area of given frame in the area: Bounds
as Vec
sourcepub fn all_iter(&self) -> impl Iterator<Item = &Texel>
pub fn all_iter(&self) -> impl Iterator<Item = &Texel>
Iterator for list of Texel
for all frames in the sprite
sourcepub fn all_iter_mut(&mut self) -> impl Iterator<Item = &mut Texel>
pub fn all_iter_mut(&mut self) -> impl Iterator<Item = &mut Texel>
Mutable iterator for list of Texel
for all frames in the sprite
sourcepub fn frame_iter(&self) -> impl Iterator<Item = &Texel>
pub fn frame_iter(&self) -> impl Iterator<Item = &Texel>
Iterator over current frame’s list of Texel
sourcepub fn frame_iter_mut(&mut self) -> impl Iterator<Item = &mut Texel>
pub fn frame_iter_mut(&mut self) -> impl Iterator<Item = &mut Texel>
Mutable iterator over current frame’s list of Texel
sourcepub fn from_txt_file(abs_path: &Path) -> Result<Self, Error>
pub fn from_txt_file(abs_path: &Path) -> Result<Self, Error>
Creates a sprite from given text file with default styles and colors
sourcepub fn from_texels(texels: Texels) -> Sprite
pub fn from_texels(texels: Texels) -> Sprite
Creates a sprite from list of texels, single frame
sourcepub fn fill_color(&mut self, cm: ColorMode, color: u8) -> bool
pub fn fill_color(&mut self, cm: ColorMode, color: u8) -> bool
Fills entire frame with color according to the ColorMode
sourcepub fn fill_style(&mut self, style: SymbolStyle) -> bool
pub fn fill_style(&mut self, style: SymbolStyle) -> bool
Fills entire frame with given SymbolStyle
sourcepub fn apply_symbol(
&mut self,
symbol: char,
bg: u8,
fg: u8,
area: Bounds
) -> Bounds
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
sourcepub fn apply_texels(&mut self, texels: Texels, pos: Position2D) -> Bounds
pub fn apply_texels(&mut self, texels: Texels, pos: Position2D) -> Bounds
Applies texels starting at given pos Position2D
sourcepub fn apply_color(&mut self, cm: ColorMode, color: u8, area: Bounds) -> bool
pub fn apply_color(&mut self, cm: ColorMode, color: u8, area: Bounds) -> bool
Applies color according to ColorMode
in the given Bounds
area
sourcepub fn apply_style(&mut self, style: SymbolStyle, area: Bounds) -> bool
pub fn apply_style(&mut self, style: SymbolStyle, area: Bounds) -> bool
Applies a single style for the given Bounds
area
sourcepub fn clear_symbol(&mut self, area: Bounds) -> Option<Bounds>
pub fn clear_symbol(&mut self, area: Bounds) -> Option<Bounds>
Removes texels in given Bounds
area