pub struct Animation(/* private fields */);
Expand description
A lottie animation.
Implementations§
Source§impl Animation
impl Animation
Sourcepub fn from_file<P>(path: P) -> Option<Self>
pub fn from_file<P>(path: P) -> Option<Self>
Constructs an animation object from file path. This file needs to be in JSON format; if you want to read telegram’s tgs files, you need to decompress them first.
Note that the rlottie library might cache the file and/or its resources.
Sourcepub fn from_data<D, K, P>(
json_data: D,
cache_key: K,
resource_path: P,
) -> Option<Self>
pub fn from_data<D, K, P>( json_data: D, cache_key: K, resource_path: P, ) -> Option<Self>
Constructs an animation object from JSON string data. External resources are
resolved relative to resource_path
.
Note that the cache_key
might be used by the rlottie library to cache the
json data and/or its resources.
This method will panic if json_data or cache_key contain nul bytes.
Sourcepub fn totalframe(&self) -> usize
pub fn totalframe(&self) -> usize
Return the total number of frames in this animation.
Sourcepub fn frame_at_pos(&self, pos: f32) -> usize
pub fn frame_at_pos(&self, pos: f32) -> usize
Maps position to frame number and returns it.
Sourcepub fn render(&mut self, frame_num: usize, surface: &mut Surface)
pub fn render(&mut self, frame_num: usize, surface: &mut Surface)
Render the contents of a frame onto the surface.
pub fn set_fill_color(&mut self, keypath: &str, color: Rgb)
pub fn set_fill_opacity(&mut self, keypath: &str, opacity: f64)
pub fn set_stroke_color(&mut self, keypath: &str, color: Rgb)
pub fn set_stroke_opacity(&mut self, keypath: &str, opacity: f64)
pub fn set_stroke_width(&mut self, keypath: &str, width: f64)
pub fn set_tr_position(&mut self, keypath: &str, x: f64, y: f64)
pub fn set_tr_scale(&mut self, keypath: &str, width: f64, height: f64)
pub fn set_tr_rotation(&mut self, keypath: &str, rotation: f64)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Animation
impl RefUnwindSafe for Animation
impl !Send for Animation
impl !Sync for Animation
impl Unpin for Animation
impl UnwindSafe for Animation
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
Mutably borrows from an owned value. Read more