animato_path/lib.rs
1//! # animato-path
2//!
3//! Motion-path primitives for Animato.
4//!
5//! This crate provides Bezier curves, CatmullRom splines, compound paths,
6//! SVG `d` attribute parsing, and [`MotionPathTween`] for driving an object
7//! along a path with the existing tween system.
8//!
9//! ## Quick Start
10//!
11//! ```rust,ignore
12//! use animato_core::{Easing, Update};
13//! use animato_path::{CubicBezierCurve, MotionPathTween};
14//!
15//! let path = CubicBezierCurve::new(
16//! [0.0, 0.0],
17//! [50.0, 100.0],
18//! [150.0, -100.0],
19//! [200.0, 0.0],
20//! );
21//! let mut motion = MotionPathTween::new(path)
22//! .duration(1.0)
23//! .easing(Easing::EaseInOutSine)
24//! .auto_rotate(true)
25//! .build();
26//!
27//! motion.update(0.5);
28//! let position = motion.value();
29//! assert!(position[0] > 0.0);
30//! ```
31//!
32//! ## Feature Flags
33//!
34//! | Feature | Effect |
35//! |---------|--------|
36//! | `std` | Enables all path types and forwards `std` to dependencies |
37//! | `alloc` | Enables heap-backed paths, SVG parser, and `MotionPathTween` |
38//! | `serde` | Derives `Serialize`/`Deserialize` on supported public types |
39
40#![cfg_attr(not(feature = "std"), no_std)]
41#![deny(missing_docs)]
42#![deny(missing_debug_implementations)]
43
44#[cfg(any(feature = "std", feature = "alloc"))]
45extern crate alloc;
46
47pub mod bezier;
48pub mod draw;
49pub(crate) mod math;
50
51#[cfg(any(feature = "std", feature = "alloc"))]
52pub mod morph;
53#[cfg(any(feature = "std", feature = "alloc"))]
54pub mod motion;
55#[cfg(any(feature = "std", feature = "alloc"))]
56pub mod poly;
57#[cfg(any(feature = "std", feature = "alloc"))]
58pub mod svg;
59
60pub use bezier::{CubicBezierCurve, PathEvaluate, QuadBezier};
61pub use draw::{DrawSvg, DrawValues};
62
63#[cfg(any(feature = "std", feature = "alloc"))]
64pub use bezier::CatmullRomSpline;
65#[cfg(any(feature = "std", feature = "alloc"))]
66pub use morph::{MorphPath, resample};
67#[cfg(any(feature = "std", feature = "alloc"))]
68pub use motion::{MotionPath, MotionPathTween, MotionPathTweenBuilder};
69#[cfg(any(feature = "std", feature = "alloc"))]
70pub use poly::{CompoundPath, EllipticalArc, LineSegment, PathCommand, PathSegment, PolyPath};
71#[cfg(any(feature = "std", feature = "alloc"))]
72pub use svg::{SvgPathError, SvgPathParser};