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
impl Animation
Sourcepub fn from_str(json: impl AsRef<str>) -> Option<Self>
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.
Sourcepub fn from_bytes(json: &[u8]) -> Option<Self>
pub fn from_bytes(json: &[u8]) -> Option<Self>
Parse a Lottie animation from JSON bytes.
Returns None if the data cannot be parsed.
Sourcepub fn from_file(path: impl AsRef<Path>) -> Option<Self>
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.
Sourcepub fn version(&self) -> Handle<SkString>
pub fn version(&self) -> Handle<SkString>
Returns the Lottie format version string from the animation file.
Sourcepub fn seek(&self, t: f32)
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.
Sourcepub fn seek_frame(&self, frame: f64)
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.
Sourcepub fn seek_frame_time(&self, time: f64)
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.
Sourcepub fn render(&self, canvas: &Canvas, dst: impl Into<Option<Rect>>)
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.
Sourcepub fn render_with_flags(
&self,
canvas: &Canvas,
dst: impl Into<Option<Rect>>,
flags: RenderFlags,
)
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.