Animation

Type Alias Animation 

Source
pub type Animation = RCHandle<skottie_Animation>;
Expand description

A Lottie animation that can be rendered to a canvas.

Animations are reference-counted and can be cloned cheaply.

Aliased Type§

pub struct Animation(/* private fields */);

Implementations§

Source§

impl Animation

Source

pub fn from_str(json: impl AsRef<str>) -> Option<Self>

Parse a Lottie animation from a JSON string.

Returns None if the string cannot be parsed.

Source

pub fn from_bytes(json: &[u8]) -> Option<Self>

Parse a Lottie animation from JSON bytes.

Returns None if the data cannot be parsed.

Source

pub fn from_file(path: impl AsRef<Path>) -> Option<Self>

Load a Lottie animation from a file path.

Returns None if the file cannot be loaded or parsed. Note: This will return None for non-UTF8 paths or paths containing null bytes.

Source

pub fn version(&self) -> Handle<SkString>

Returns the Lottie format version string from the animation file.

Source

pub fn duration(&self) -> f32

Returns the animation duration in seconds.

Source

pub fn fps(&self) -> f32

Returns the animation frame rate (frames per second).

Source

pub fn in_point(&self) -> f32

Returns the first frame index (usually 0).

Source

pub fn out_point(&self) -> f32

Returns the last frame index.

Source

pub fn size(&self) -> Size

Returns the intrinsic animation size.

Source

pub fn seek(&self, t: f32)

Seek to a normalized position in the animation.

t is in the range [0, 1] where 0 is the first frame and 1 is the last frame.

Note: This method uses interior mutability as the underlying Skia animation state is updated internally.

Source

pub fn seek_frame(&self, frame: f64)

Seek to a specific frame number.

Frame numbers are in the range [in_point(), out_point()]. Fractional frame values are supported for sub-frame accuracy.

Note: This method uses interior mutability as the underlying Skia animation state is updated internally.

Source

pub fn seek_frame_time(&self, time: f64)

Seek to a specific time in seconds.

Time is in the range [0, duration()].

Note: This method uses interior mutability as the underlying Skia animation state is updated internally.

Source

pub fn render(&self, canvas: &Canvas, dst: impl Into<Option<Rect>>)

Render the current frame to the canvas.

If dst is provided, the animation is scaled/positioned to fit the rectangle. If dst is None, the animation is rendered at its intrinsic size at the origin.

Source

pub fn render_with_flags( &self, canvas: &Canvas, dst: impl Into<Option<Rect>>, flags: RenderFlags, )

Render the current frame to the canvas with additional flags.

If dst is provided, the animation is scaled/positioned to fit the rectangle. If dst is None, the animation is rendered at its intrinsic size at the origin.

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 Send for Animation

Source§

impl Sync for Animation