Tessellation of 2D fill and stroke operations.
This crate is reexported in lyon.
The most interesting types and traits of this crate are:
- FillTessellator - Tessellator for complex path fill operations.
- StrokeTessellator - Tessellator for complex path stroke operations.
GeometryBuilder- (See the documentation of the geometry_builder module) which the above two are built on. This trait provides an interface for types that help with building and assembling the vertices and triangles that form the tessellation, usually in the form of arbitrary vertex and index buffers.
- The various specialized tessellators in the
The figure above shows each step of the fill tessellation pipeline.
Tessellating strokes works the same way using
StrokeVertex instead of
The path tessellators are not tied to a particular data structure. Instead they consume iterators of flattened path events. A Path struct in the crate lyon_path is provided for convenience (but is optional).
The tessellators are parametrized over a type implementing the GeometryBuilder trait. This trait provides some simple methods to add vertices and triangles, without enforcing any particular representation for the resulting geometry. This is important because each application will usually want to work with its own vertex type tailored a certain rendering model.
Applications can implement the
GeometryBuilder<Point> trait in order to
generate vertex buffers and index buffers with custom vertex types.
BuffersBuilder is generic over a
VertexConstructor<InputVertex, OutputVertex> trait which
creates the application's output vertices from the tessellator input vertices (either
The tessellators produce geometry in the form of vertex and index buffers which are expected
to be rendered using the equivalent of OpenGL's
glDrawElements with mode
under various names in the different graphics APIs.
There is a basic example showing how
it can be done with gfx-rs.
Most tessellators in this crate currently operate on flattened paths (paths or shapes represented
by sequences of line segments). when paths contain bézier curves or arcs, the latter need to be
approximated with sequences of line segments. This approximation depends on a
which represents the maximum distance between a curve and its flattened approximation.
More explanation about flattening and tolerance in the lyon_geom crate.
Tessellation routines for simple shapes.
Tools to help with generating vertex and index buffers.
Basic types that are used everywhere. Most other lyon crates reexport them.
A temporary view on a
Number of vertices and indices added during the tessellation.
A sequence of edges sorted from top to bottom, to be used as the tessellator's input.
Parameters for the fill tessellator.
A Context object that can tessellate fill operations for complex paths.
Vertex produced by the fill tessellators.
A builder that tessellates a stroke directly without allocating any intermediate data structure.
Parameters for the tessellator.
A Context object that can tessellate stroke operations for complex paths.
Vertex produced by the stroke tessellators.
Structure that holds the vertex and index data.
The fill rule defines how to determine what is inside and what is outside of the shape.
Something unexpectedly put the tessellator in a bad state.
Line cap as defined by the SVG specification.
Line join as defined by the SVG specification.
Defines the tessellator the should try to behave when detecting an error.
Before or After. Used to describe position relative to a join.
Left or right.
The fill tessellator's error enumeration.
An interface separating tessellators and other geometry generation algorithms from the actual vertex construction.
An interface with similar goals to
A trait specifying how to create vertex values.
The fill tessellator's result type.