Skip to main content

Crate spanda

Crate spanda 

Source
Expand description

§spanda

Sanskrit: स्पन्द — vibration, pulse, the throb of motion.

A general-purpose animation library for Rust. Zero mandatory dependencies, no_std-ready, and designed to work anywhere: terminal UIs, web (WASM), game engines (Bevy), or native desktop apps.

§Feature flags

FlagWhat it adds
std(default) wall-clock driver, thread-safe internals
serdeSerialize/Deserialize on all public types
bevySpandaPlugin for Bevy 0.13
wasmrequestAnimationFrame driver
paletteColour interpolation via the palette crate
tokioasync / .await on timeline completion

§Quick start

use spanda::{Tween, Easing};
use spanda::traits::Update;

let mut tween = Tween::new(0.0_f32, 100.0)
    .duration(1.0)
    .easing(Easing::EaseOutCubic)
    .build();

// Simulate 10 frames:
for _ in 0..10 {
    tween.update(0.1);
}

assert!(tween.is_complete());
assert!((tween.value() - 100.0).abs() < 1e-6);

Re-exports§

pub use easing::Easing;
pub use traits::Animatable;
pub use traits::Interpolate;
pub use traits::Update;
pub use tween::Tween;
pub use tween::TweenState;
pub use tween::snap_to;
pub use tween::round_to;
pub use keyframe::KeyframeTrack;
pub use keyframe::Keyframe;
pub use keyframe::Loop;
pub use timeline::Timeline;
pub use timeline::Sequence;
pub use timeline::At;
pub use timeline::stagger;
pub use spring::Spring;
pub use spring::SpringConfig;
pub use spring::SpringN;
pub use spring::SpringAnimatable;
pub use driver::AnimationDriver;
pub use driver::AnimationId;
pub use clock::Clock;
pub use clock::ManualClock;
pub use clock::MockClock;
pub use scroll::ScrollClock;
pub use scroll::ScrollDriver;
pub use path::BezierPath;
pub use path::MotionPath;
pub use path::MotionPathTween;
pub use path::PathEvaluate;
pub use bezier::CatmullRomSpline;
pub use bezier::PathEvaluate2D;
pub use bezier::tangent_angle;
pub use bezier::tangent_angle_deg;
pub use motion_path::PolyPath;
pub use motion_path::CompoundPath;
pub use motion_path::PathCommand;
pub use svg_path::SvgPathParser;
pub use svg_draw::draw_on;
pub use svg_draw::draw_on_reverse;
pub use morph::MorphPath;
pub use morph::resample;
pub use inertia::Inertia;
pub use inertia::InertiaN;
pub use inertia::InertiaConfig;
pub use drag::DragState;
pub use drag::DragConstraints;
pub use drag::DragAxis;
pub use drag::PointerData;
pub use layout::LayoutAnimator;
pub use layout::LayoutAnimation;
pub use layout::LayoutTransition;
pub use layout::Rect;
pub use layout::SharedElementTransition;
pub use gesture::GestureRecognizer;
pub use gesture::Gesture;
pub use gesture::GestureConfig;
pub use gesture::SwipeDirection;
pub use clock::WallClock;

Modules§

bezier
Catmull-Rom spline — smooth curve through a sequence of points.
clock
Clock abstractions for decoupling animation from wall time.
drag
Pure-math drag state tracker and pointer data.
driver
Animation driver — manages a collection of active animations.
easing
Easing functions — the feel of every animation.
gesture
Higher-level gesture recognition built on top of PointerData.
inertia
Inertia-based deceleration — friction physics without a target.
integrations
Integration modules for specific platforms and engines.
keyframe
Multi-stop keyframe animation tracks.
layout
Automatic FLIP-style layout animation.
morph
Shape morphing — lerp between two sets of 2D control points.
motion_path
Advanced 2D motion path system — GSAP-equivalent path animation.
path
Bezier paths and motion path interpolation.
scroll
Scroll-linked animation driver.
spring
Physics-based spring animation — a damped harmonic oscillator.
svg_draw
DrawSVG helper — animate stroke-dashoffset for SVG path drawing effects.
svg_path
SVG path string parser — converts SVG d attribute strings to PathCommands.
timeline
Timeline and Sequence — compose multiple animations together.
traits
Core traits that power the entire spanda animation system.
tween
Single-value animation — the most common building block.