Struct rlottie::Animation

source ·
pub struct Animation(_);
Expand description

A lottie animation.

Implementations§

source§

impl Animation

source

pub fn from_file<P>(path: P) -> Option<Self>where P: AsRef<Path>,

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.

source

pub fn from_data<D, K, P>( json_data: D, cache_key: K, resource_path: P ) -> Option<Self>where D: Into<Vec<u8>>, K: Into<Vec<u8>>, P: AsRef<Path>,

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.

source

pub fn size(&self) -> Size

Return the default viewport size of this animation.

source

pub fn duration(&self) -> f64

Return the total duration of this animation in seconds.

source

pub fn totalframe(&self) -> usize

Return the total number of frames in this animation.

source

pub fn framerate(&self) -> f64

Return the default framerate of this animation.

source

pub fn frame_at_pos(&self, pos: f32) -> usize

Maps position to frame number and returns it.

source

pub fn render(&mut self, frame_num: usize, surface: &mut Surface)

Render the contents of a frame onto the surface.

source

pub fn set_fill_color(&mut self, keypath: &str, color: Rgb)

source

pub fn set_fill_opacity(&mut self, keypath: &str, opacity: f64)

source

pub fn set_stroke_color(&mut self, keypath: &str, color: Rgb)

source

pub fn set_stroke_opacity(&mut self, keypath: &str, opacity: f64)

source

pub fn set_stroke_width(&mut self, keypath: &str, width: f64)

source

pub fn set_tr_position(&mut self, keypath: &str, x: f64, y: f64)

source

pub fn set_tr_scale(&mut self, keypath: &str, width: f64, height: f64)

source

pub fn set_tr_rotation(&mut self, keypath: &str, rotation: f64)

Trait Implementations§

source§

impl Debug for Animation

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for Animation

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.