Skip to main content

MorphPath

Struct MorphPath 

Source
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, ResourceStore, 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().after_origin());
assert!(middle.bounding_box()?.is_finite());

Implementations§

Source§

impl MorphPath

Source

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.

Source

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.

Source

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.

Source

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 Clone for MorphPath

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MorphPath

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Interpolate for MorphPath

Source§

fn interpolate(&self, target: &Self, progress: f64) -> Self

Blends toward target with nominal progress zero at self and one at target. Read more
Source§

impl PartialEq for MorphPath

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Shape for MorphPath

Source§

fn path(&self) -> Result<Path2D, ValidationError>

Returns a checked path snapshot without f32 narrowing.
Source§

fn bounding_box(&self) -> Result<Rect, ValidationError>

Geometric bounds; defaults to the path’s cached curve bounds.
Source§

fn as_rect(&self) -> Option<Rect>

Exact rectangle equivalent, when available, for a rule-independent fast path.
Source§

fn fill(self, paint: impl Into<Paint>) -> Styled<Self>
where Self: Sized,

Adds floating fill paint, using the nonzero rule by default.
Source§

fn stroke(self, width: f64, paint: impl Into<Paint>) -> Styled<Self>
where Self: Sized,

Adds a bounded curve/path stroke without an implicit fill.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<Geometry> IntoShapeClip for Geometry
where Geometry: Shape,

Source§

fn into_shape_clip(self) -> Result<ShapeClip, ValidationError>

Captures the clip geometry, reporting invalid shapes.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.