Lyon path builder
Tools to iterate over path objects.
Overview
This crate provides a collection of traits to extend the Iterator trait with
information about the state of the cursor moving along the path. This is useful
because the way some events are described require to have information about the
previous events. For example the event LinTo
gives the next position and it is
generally useful to have access to the current position in order to make something
out of it. Likewise, Some Svg events are given in relative coordinates and/or
are expressed in a way that the first control point is deduced from the position
of the previous control point.
All of this extra information is conveniently exposed in the PathState
struct
that can be accessed by PathIterator
, SvgIterator
and FlattenedIterator
.
The PathIter<Iter>
adapter automatically implements PathIterator
for
any Iter
that implements Iterator<PathEvent>
This crate provides adapters between these iterator types. For example iterating over a sequence of SVG events can be automatically translated into iterating over simpler path events which express all positions with absolute coordinates, among other things.
The trait FlattenedIterator
is what some of the tessellation algorithms
of the lyon_tessellation
crate take as input.
Examples
extern crate lyon_path_iterator;
use *;
use ;
An equivalent (but shorter) version of the above code takes advantage of the
fact you can get a flattening iterator directly from an SvgIterator
:
extern crate lyon_path_iterator;
use *;
use ;