pub trait DrawSvg {
// Required method
fn total_length(&self) -> f32;
// Provided methods
fn draw_on(&self, progress: f32) -> DrawValues { ... }
fn draw_on_reverse(&self, progress: f32) -> DrawValues { ... }
}Expand description
Trait for animating SVG path drawing via stroke-dashoffset.
Automatically implemented for every type that implements PathEvaluate.
§Example
ⓘ
use animato_path::{CubicBezierCurve, DrawSvg};
let path = CubicBezierCurve::new([0.0, 0.0], [50.0, 100.0], [150.0, -100.0], [200.0, 0.0]);
let values = path.draw_on(0.5); // 50% drawn
println!("dasharray={} dashoffset={}", values.dash_array, values.dash_offset);Required Methods§
Sourcefn total_length(&self) -> f32
fn total_length(&self) -> f32
Total arc length of the drawable path.
Provided Methods§
Sourcefn draw_on(&self, progress: f32) -> DrawValues
fn draw_on(&self, progress: f32) -> DrawValues
Compute stroke-dasharray / stroke-dashoffset values to draw the
path forward from the start to progress ∈ [0.0, 1.0].
At 0.0 the path is invisible; at 1.0 it is fully drawn.
Sourcefn draw_on_reverse(&self, progress: f32) -> DrawValues
fn draw_on_reverse(&self, progress: f32) -> DrawValues
Compute values for erasing the path from the end back toward the start.
At 0.0 the path is fully drawn; at 1.0 it is invisible.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<T: PathEvaluate> DrawSvg for T
Blanket implementation: every PathEvaluate type is also DrawSvg.