Skip to main content

fastanim_core/
lib.rs

1//! Core model for fastanim: geometry, mobject state, animations, the scene builder and the
2//! baked, seekable timeline (see `docs/SPEC.md` ยง4).
3//!
4//! Has no Bevy dependency so it can be tested with plain `cargo test`.
5
6pub mod anim;
7pub mod axes;
8pub mod color;
9pub mod geom;
10pub mod mobject;
11pub mod position;
12pub mod svg;
13pub mod timeline;
14pub mod transform_diff;
15
16pub use fastanim_diff::Op;
17pub use kurbo;
18pub use kurbo::{Point, Vec2};
19
20pub use anim::{
21    Animation, AnimationExt, Ease, LaggedStart, Overlay, Parallel, RateFn, ReplacementTransform,
22    Sequence, Transform, Unwrite, Update, UpdateGroup, apply_function, circumscribe, create,
23    draw_border_then_fill, fade_in, fade_out, flash, grow_from_center, indicate, lagged_start,
24    move_to, replacement_transform, rotate, scale, shift, shrink_to_center, spin_in, transform,
25    uncreate, unwrite, wiggle, write,
26};
27pub use axes::Axes;
28pub use color::Color;
29pub use geom::{SubPath, VPath, align};
30pub use mobject::{MobjectId, SceneState, Stroke, VState};
31pub use position::{DEFAULT_BUFF, EDGE_BUFF, Position, arrange};
32pub use svg::to_svg;
33pub use timeline::{BakedTimeline, Scene};
34pub use transform_diff::{DiffStyle, Group, Layout, Phasing, ReplaceStyle, TransformDiff};
35
36/// Values that can be blended; `lerp(a, b, 0) == a` and `lerp(a, b, 1) == b`.
37pub trait Interpolate: Clone {
38    /// Blends `a` towards `b` by `t` in `0..=1`.
39    fn lerp(a: &Self, b: &Self, t: f32) -> Self;
40}
41
42/// Frame height in scene units (manim's).
43pub const FRAME_HEIGHT: f64 = 8.0;
44/// Frame width in scene units: 16:9.
45pub const FRAME_WIDTH: f64 = FRAME_HEIGHT * 16.0 / 9.0;
46
47/// Unit vector up (y is up).
48pub const UP: Vec2 = Vec2::new(0.0, 1.0);
49/// Unit vector down.
50pub const DOWN: Vec2 = Vec2::new(0.0, -1.0);
51/// Unit vector left.
52pub const LEFT: Vec2 = Vec2::new(-1.0, 0.0);
53/// Unit vector right.
54pub const RIGHT: Vec2 = Vec2::new(1.0, 0.0);
55/// The origin.
56pub const ORIGIN: Point = Point::ORIGIN;