pub struct AnimatedIndexedImage { /* private fields */ }
Expand description
Series of images to play as an animation
§Usage
[set_animate] to play/pause Call [update] in your UI/game update method, passing in your time step delta
Implementations§
Source§impl AnimatedIndexedImage
impl AnimatedIndexedImage
Sourcepub fn set_palette(
&mut self,
palette: &[Color],
) -> Result<(), IndexedImageError>
pub fn set_palette( &mut self, palette: &[Color], ) -> Result<(), IndexedImageError>
Replace palette for image Will only return an error if the new palette has less colors than the image needs
Sourcepub fn set_palette_replace_id(
&mut self,
palette: &[Color],
id: u8,
) -> Result<(), IndexedImageError>
pub fn set_palette_replace_id( &mut self, palette: &[Color], id: u8, ) -> Result<(), IndexedImageError>
Replace palette for image, any pixels outside the new palette will be replaced with id
Will only return an error if id is outside the new palette
Sourcepub fn set_palette_replace_color<C>(&mut self, palette: &[Color], color: C)
pub fn set_palette_replace_color<C>(&mut self, palette: &[Color], color: C)
Replace palette for image, any color indexes outside the palette will be expanded with color
pub fn size(&self) -> (u8, u8)
Sourcepub fn set_pixel(
&mut self,
frame: u8,
pixel_idx: usize,
color_idx: u8,
) -> Result<(), IndexedImageError>
pub fn set_pixel( &mut self, frame: u8, pixel_idx: usize, color_idx: u8, ) -> Result<(), IndexedImageError>
This is unchecked and if color_idx > min_palette_size_supported will crash when rendering
pub fn get_pixels(&self) -> &[u8] ⓘ
pub fn get_frame_pixels(&self, idx: u8) -> Result<&[u8], IndexedImageError>
pub fn get_current_frame_pixels(&self) -> &[u8] ⓘ
pub fn get_pixel( &self, frame: u8, pixel_idx: usize, ) -> Result<u8, IndexedImageError>
pub fn get_pixel_index(&self, x: u8, y: u8) -> Result<usize, IndexedImageError>
pub fn as_images(&self) -> Vec<IndexedImage>
pub fn get_frame(&self, idx: usize) -> IndexedImage
pub fn get_color(&self, idx: u8) -> Result<Color, IndexedImageError>
pub fn set_color( &mut self, idx: u8, color: Color, ) -> Result<(), IndexedImageError>
pub fn get_palette(&self) -> &[Color]
pub fn min_palette_size_supported(&self) -> u8
pub fn get_per_frame(&self) -> f64
pub fn set_per_frame(&mut self, seconds: f64)
pub fn set_animate(&mut self, animate: bool)
pub fn animating(&self) -> bool
pub fn width(&self) -> u8
pub fn height(&self) -> u8
pub fn frame_count(&self) -> u8
Sourcepub fn skip_to_next_frame(&mut self)
pub fn skip_to_next_frame(&mut self)
Doesn’t go to next frame until [update] is called
Sourcepub fn delay_next_frame(&mut self, seconds: f64)
pub fn delay_next_frame(&mut self, seconds: f64)
Add seconds
as one off dely for next frame
pub fn play_type(&self) -> PlayType
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Frame timer to per frame and then depending on play type
- Once - Frame to 0, playing to false
- OnceReversed - Frame to end, playing to false
- Looping - Frame to 0, playing to true
- LoopingReversed - Frame to end, playing to true
- LoopingBoth - Frame to 0, playing to true
Sourcepub fn set_play_type(&mut self, play_type: PlayType)
pub fn set_play_type(&mut self, play_type: PlayType)
Sets play type and [reset]s
Sourcepub fn set_just_play_type(&mut self, play_type: PlayType)
pub fn set_just_play_type(&mut self, play_type: PlayType)
Like [set_play_type] but doesn’t change anything else
Source§impl AnimatedIndexedImage
impl AnimatedIndexedImage
Sourcepub fn to_file_contents(
&self,
palette: &FilePalette,
) -> Result<Vec<u8>, IndexedImageError>
pub fn to_file_contents( &self, palette: &FilePalette, ) -> Result<Vec<u8>, IndexedImageError>
Errors will only be returned if you FilePalette::Name and the len is invalid
Sourcepub fn from_file_contents(
bytes: &[u8],
) -> Result<(AnimatedIndexedImage, FilePalette), IndexedImageError>
pub fn from_file_contents( bytes: &[u8], ) -> Result<(AnimatedIndexedImage, FilePalette), IndexedImageError>
Create an AnimatedIndexedImage, image palette will be filled with transparency unless file contains colors
use image.set_palette*
to replace the palette
Trait Implementations§
Source§impl ChangeColors for AnimatedIndexedImage
impl ChangeColors for AnimatedIndexedImage
Source§fn with_saturate(&self, amount: f32) -> AnimatedIndexedImage
fn with_saturate(&self, amount: f32) -> AnimatedIndexedImage
-0.1
is 10% more saturatedSource§fn with_brightness(&self, amount: f32) -> AnimatedIndexedImage
fn with_brightness(&self, amount: f32) -> AnimatedIndexedImage
amount
So 1.1
is 10% brighterSource§fn desaturate(&self) -> Selfwhere
Self: Sized,
fn desaturate(&self) -> Selfwhere
Self: Sized,
fn lighten(&self) -> Selfwhere
Self: Sized,
fn darken(&self) -> Selfwhere
Self: Sized,
Source§impl Clone for AnimatedIndexedImage
impl Clone for AnimatedIndexedImage
Source§fn clone(&self) -> AnimatedIndexedImage
fn clone(&self) -> AnimatedIndexedImage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for AnimatedIndexedImage
impl Debug for AnimatedIndexedImage
Source§impl From<AnimatedIndexedImage> for IndexedWrapper
impl From<AnimatedIndexedImage> for IndexedWrapper
Source§fn from(value: AnimatedIndexedImage) -> IndexedWrapper
fn from(value: AnimatedIndexedImage) -> IndexedWrapper
Source§impl PartialEq for AnimatedIndexedImage
impl PartialEq for AnimatedIndexedImage
impl StructuralPartialEq for AnimatedIndexedImage
Auto Trait Implementations§
impl Freeze for AnimatedIndexedImage
impl RefUnwindSafe for AnimatedIndexedImage
impl Send for AnimatedIndexedImage
impl Sync for AnimatedIndexedImage
impl Unpin for AnimatedIndexedImage
impl UnwindSafe for AnimatedIndexedImage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.