pub trait Pattern {
    // Required method
    fn next(
        &mut self,
        position: Point,
        tangent: Vector,
        distance: f32
    ) -> Option<f32>;

    // Provided method
    fn begin(&mut self, distance: f32) -> Option<f32> { ... }
}
Expand description

Types implementing the Pattern can be used to walk along a path at constant speed.

At each step, the pattern receives the position, tangent and already traversed distance along the path and returns the distance until the next step.

See the RegularPattern and RepeatedPattern implementations. This trait is also implemented for all functions/closures with signature FnMut(Point, Vector, f32) -> Option<f32>.

Required Methods§

source

fn next( &mut self, position: Point, tangent: Vector, distance: f32 ) -> Option<f32>

This method is invoked at each step along the path.

If this method returns None, path walking stops. Otherwise the returned value is the distance along the path to the next element in the pattern.

Provided Methods§

source

fn begin(&mut self, distance: f32) -> Option<f32>

Invoked at the start each sub-path.

Takes the leftover requested distance from the previous sub-path path, if any.

If this method returns None, path walking stops. Otherwise the returned value is the distance along the path to the next element in the pattern.

Implementors§

source§

impl<'l, Cb> Pattern for RepeatedPattern<'l, Cb>
where Cb: FnMut(Point, Vector, f32) -> bool,

source§

impl<Cb> Pattern for RegularPattern<Cb>
where Cb: FnMut(Point, Vector, f32) -> bool,

source§

impl<Cb> Pattern for Cb
where Cb: FnMut(Point, Vector, f32) -> Option<f32>,