pub struct MotionPathConfig {
pub path: String,
pub delay: f64,
pub duration: f64,
pub repeat: bool,
pub orient: bool,
pub orient_offset: f64,
pub easing: EasingType,
}Expand description
Configuration for the motion_path animation effect: moves — and,
optionally, orients — a component along an SVG path.
§Path syntax
path is the SVG path d-attribute mini-language (M/L/H/V/C/
S/Q/T/A/Z, absolute or relative) — the exact syntax shape’s
ShapeType::Path { data } already accepts and parses with
skia_safe::Path::from_svg (engine/renderer/shapes.rs). This effect
reuses that same call rather than inventing a second path grammar, and
measures the parsed path with skia_safe::PathMeasure — the exact
primitive svg.rs (dash-reveal of an SVG document’s paths) and
arrow.rs (dash-reveal of a bezier curve, plus its own tangent-based
arrowhead orientation) already use for draw_progress. orient’s
tangent-to-degrees math is the same atan2(tangent.y, tangent.x) idiom
arrow.rs::draw_arrowhead already computes for its arrowhead.
§Coordinate space
Path coordinates are pixel deltas relative to wherever CSS layout
placed the component absent this effect — the same convention orbit
already uses for its circular motion (see OrbitConfig/apply_orbits),
and the only one implementable here: the resolver this effect plugs into
(engine::animator::resolve_props_for_effects) receives only
(effects, time, scene_duration) — never the component’s resolved
layout box or the viewport, which are computed downstream in
paint_pass.rs/box_builder.rs. So "M0,0 L200,0" slides the
component 200px right of its laid-out position (and back, if the effect
loops); "M100,0 L300,0" starts the component already displaced 100px
right of its laid-out position — a direct, intentional consequence of
treating the whole path as a translate delta, not a bug to normalize
away.
§Degenerate paths
- Empty or syntactically invalid
path(e.g."", garbage text) is rejected at JSON-parse time by [deserialize_motion_path_data] — a named error, never a silent no-op, mirroring [deserialize_motion_property]’s treatment of an unrecognisedwiggle/keyframesproperty name. - Zero measured length (a single point, e.g.
"M50,50", or every segment collapsing onto one point) is syntactically valid SVG and is not rejected at parse time — it has a well-defined render-time meaning: the component holds at that single point for the whole timeline, andorient(if set) contributes no rotation (a tangent is undefined at zero length) instead of propagating a NaN. Seeengine::animator::motion_path_sample.validate_schema.rsflags it as a (non-blocking) warning, since it is very likely — but not certainly — an authoring mistake (e.g. duplicated coordinates).
Fields§
§path: StringSVG path data (the d-attribute mini-language). Must contain at
least one drawable point — an empty or unparsable path is rejected
at deserialize time (see [deserialize_motion_path_data]).
delay: f64Delay before travel starts (seconds). Before this, the component
sits at the path’s start point (progress 0) — the same “hold at the
entrance state” behaviour every other preset/effect with a delay
already has.
duration: f64Time to travel the whole path once (seconds).
repeat: boolLoop the traversal continuously instead of holding at the path’s end
once delay + duration has elapsed.
orient: boolRotate the component to face the path’s tangent direction (default false — position without orientation, e.g. for content that should stay upright while it moves).
orient_offset: f64Degrees added on top of the tangent-derived rotation, for assets
whose drawn “forward” direction is not +X (default 0.0). E.g. an
icon drawn pointing up needs orient_offset: 90.
easing: EasingTypeEasing applied to progress along the path (default linear — constant
speed along the curve, the expected default for a hand-authored
trajectory; ease_in/ease_out bunches travel toward one end).
Trait Implementations§
Source§impl Clone for MotionPathConfig
impl Clone for MotionPathConfig
Source§fn clone(&self) -> MotionPathConfig
fn clone(&self) -> MotionPathConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MotionPathConfig
impl Debug for MotionPathConfig
Source§impl<'de> Deserialize<'de> for MotionPathConfig
impl<'de> Deserialize<'de> for MotionPathConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for MotionPathConfig
impl JsonSchema for MotionPathConfig
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreSource§impl PartialEq for MotionPathConfig
impl PartialEq for MotionPathConfig
Source§impl Serialize for MotionPathConfig
impl Serialize for MotionPathConfig
impl StructuralPartialEq for MotionPathConfig
Auto Trait Implementations§
impl Freeze for MotionPathConfig
impl RefUnwindSafe for MotionPathConfig
impl Send for MotionPathConfig
impl Sync for MotionPathConfig
impl Unpin for MotionPathConfig
impl UnsafeUnpin for MotionPathConfig
impl UnwindSafe for MotionPathConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more