Module lyon_algorithms::walk
source · Expand description
Move at a defined speed along a path.
Path walking
Overview
In principle, walking a path is similar to iterating over it, but instead of going from receiving path segments (of varying sizes), the path walker makes it possible to advance by a certain distance along the path.
Example
use lyon_algorithms::walk::{RegularPattern, walk_along_path};
use lyon_algorithms::path::PathSlice;
use lyon_algorithms::path::iterator::*;
use lyon_algorithms::path::math::Point;
fn dots_along_path(path: PathSlice, dots: &mut Vec<Point>) {
let mut pattern = RegularPattern {
callback: &mut |position, _tangent, _distance| {
dots.push(position);
true // Return true to continue walking the path.
},
// Invoke the callback above at a regular interval of 3 units.
interval: 3.0,
};
let tolerance = 0.01; // The path flattening tolerance.
let start_offset = 0.0; // Start walking at the beginning of the path.
walk_along_path(
path.iter().flattened(tolerance),
start_offset,
&mut pattern
);
}
Structs
- A helper struct to walk along a flattened path using a builder API.
- A simple pattern that invokes a callback at regular intervals.
- A pattern that invokes a callback at a repeated sequence of constant intervals.
Traits
- Types implementing the
Pattern
can be used to walk along a path at constant speed.
Functions
- Walks along the path staring at offset
start
and applies aPattern
.