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(crate) mod math;
49
50#[cfg(any(feature = "std", feature = "alloc"))]
51pub mod motion;
52#[cfg(any(feature = "std", feature = "alloc"))]
53pub mod poly;
54#[cfg(any(feature = "std", feature = "alloc"))]
55pub mod svg;
56
57pub use bezier::{CubicBezierCurve, PathEvaluate, QuadBezier};
58
59#[cfg(any(feature = "std", feature = "alloc"))]
60pub use bezier::CatmullRomSpline;
61#[cfg(any(feature = "std", feature = "alloc"))]
62pub use motion::{MotionPath, MotionPathTween, MotionPathTweenBuilder};
63#[cfg(any(feature = "std", feature = "alloc"))]
64pub use poly::{CompoundPath, EllipticalArc, LineSegment, PathCommand, PathSegment, PolyPath};
65#[cfg(any(feature = "std", feature = "alloc"))]
66pub use svg::{SvgPathError, SvgPathParser};