pub struct MorphPath { /* private fields */ }Expand description
A checked path value for geometry interpolation and fill/stroke. Original path snapshots are retained at exact animation endpoints.
use motion_core::prelude::*;
use motion_core::{
DisplayList, RasterLimits, ResourcePool, ValidatedDisplayList, MAX_PATH_VERBS,
MAX_STROKE_VERBS, MAX_SVG_PATH_BYTES, sample_offsets,
};
let (from, to) = MorphPath::pair(
Circle::new(Point::new(8.0, 8.0), 6.0).path(),
Star::new(Point::new(8.0, 8.0), 5, 6.0, 2.5).path(),
)?;
let animation = Tween::new(from, to, 1.seconds());
let middle = animation.sample(500.milliseconds());
assert!(middle.bounding_box().is_finite());Implementations§
Source§impl MorphPath
impl MorphPath
Sourcepub fn new(path: Path2D) -> Result<Self, ValidationError>
pub fn new(path: Path2D) -> Result<Self, ValidationError>
Captures a path and promotes line/quadratic segments to cubic controls. At most 64 contours are accepted; all existing path limits still apply.
Sourcepub fn pair(
source: Path2D,
target: Path2D,
) -> Result<(Self, Self), ValidationError>
pub fn pair( source: Path2D, target: Path2D, ) -> Result<(Self, Self), ValidationError>
Prepares a pair once for repeated Tween sampling, using 32 uniform arc-length landmarks plus both paths’ existing curve boundaries.
Sourcepub fn pair_with_samples(
source: Path2D,
target: Path2D,
samples: usize,
) -> Result<(Self, Self), ValidationError>
pub fn pair_with_samples( source: Path2D, target: Path2D, samples: usize, ) -> Result<(Self, Self), ValidationError>
Prepares 4..=256 arc-length landmarks per contour. Output remains capped by MAX_PATH_VERBS, with at most 64 matched contours and bounded alignment.
Sourcepub fn try_interpolate(
&self,
target: &Self,
progress: f64,
) -> Result<Self, ValidationError>
pub fn try_interpolate( &self, target: &Self, progress: f64, ) -> Result<Self, ValidationError>
Checked, stateless interpolation. Finite overshoot is allowed; exact progress 0/1 returns the original verb snapshots. Unprepared values compute correspondence on demand; prefer pair for repeated sampling.
Trait Implementations§
Source§impl Interpolate for MorphPath
impl Interpolate for MorphPath
Source§fn interpolate(&self, target: &Self, progress: f64) -> Self
fn interpolate(&self, target: &Self, progress: f64) -> Self
target with nominal progress zero at self and one at target. Read more