Skip to main content

motion_path_length

Function motion_path_length 

Source
pub fn motion_path_length(path_data: &str) -> Option<f32>
Expand description

Parse path_data and measure its length, in px — the shared primitive apply_motion_paths (render time) and validate_schema.rs’s advisory zero-length check (author time) both build on, so the two never disagree about what “degenerate” means.

Returns None when path_data is empty or not valid SVG path data. Every motion_path effect reachable through AnimationEffect already has this ruled out at JSON-parse time (schema/video.rs::deserialize_motion_path_data), so in practice None only fires if a caller builds a MotionPathConfig directly in Rust, bypassing that gate. Some(0.0) (or a value below MOTION_PATH_MIN_LENGTH) is returned for a syntactically valid path with (near-)zero measured length — a well-defined, distinct case from “invalid”, per MotionPathConfig’s “Degenerate paths” doc section.