Struct lottie2gif::Animation
source · [−]pub struct Animation(_);
Expand description
A lottie animation.
Implementations
sourceimpl Animation
impl Animation
sourcepub fn from_file<P>(path: P) -> Option<Animation> where
P: AsRef<Path>,
pub fn from_file<P>(path: P) -> Option<Animation> where
P: AsRef<Path>,
Read a lottie animation from file. This file needs to be in JSON format; if you want to read telegram’s tgs files, you need to decompress them first.
sourcepub fn from_data<P>(
data: String,
key: String,
resource_path: P
) -> Option<Animation> where
P: AsRef<Path>,
pub fn from_data<P>(
data: String,
key: String,
resource_path: P
) -> Option<Animation> where
P: AsRef<Path>,
Read a file from memory. External resources are resolved relative to resource_path
.
sourcepub fn totalframe(&self) -> u64
pub fn totalframe(&self) -> u64
Return the total number of frames in this animation.
pub fn render_tree(&mut self, frame_num: u64, size: Size) -> LayerNode
sourcepub fn frame_at_pos(&self, pos: f32) -> u64
pub fn frame_at_pos(&self, pos: f32) -> u64
Maps position to frame number and returns it.
sourcepub fn render(
&mut self,
frame_num: u64,
buffer: &mut Vec<Argb, Global>,
size: Size
) -> Result<(), RenderError>
pub fn render(
&mut self,
frame_num: u64,
buffer: &mut Vec<Argb, Global>,
size: Size
) -> Result<(), RenderError>
Render the contents of a frame into the buffer at a certain viewport size.
The buffer’s capacity must be at least size.width * size.height
. It’s initial length
or content doesn’t matter. The first size.width * size.height
bytes of the buffer
will be written to; and it’s length will be set exactly to size.width * size.height
.
This operation will fail only if the buffer’s capacity isn’t large enough.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Animation
impl !Send for Animation
impl !Sync for Animation
impl Unpin for Animation
impl UnwindSafe for Animation
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more