Crate lyon_tessellation [] [src]

Lyon Tessellation

This crate implements tools to compute the tessellation of 2d paths fill and stroke operations, in order to render them efficiently on the GPU.

Overview

The most interesting modules of this crate are:

  • path_fill - Implementing the tessellation of complex path fill operations.
  • path_stroke - Implementing the tessellation of complex path stroke operations.
  • geometry_builder - Which the above two are built on. It provides traits to facilitate generating arbitrary vertex and index buffers.

The tessellation pipeline

FillTessellator GeometryBuilder output VertexConstructor Iterator<FlattenedEvent> builder.add_vertex(FillVertex) -> VertexId;builder.add_triangle(VertexId, VertexId, VertexId); FillVertex -> CustomVertex MoveTo(Point)LineTo(Point)Close

The figure above shows each step of the fill tessellation pipeline. Tessellating strokes works the same way using StrokeVertex instead of FillVertex.

The input: iterators

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).

While the path tessellators use iterators, other more specific tessellation routines take simpler outputs like rectangles and circles. See the documentation of the basic_shapes module.

The output: geometry builders

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.

Each application will implement the GeometryBuilder<Point> trait in order to generate vertex buffers and index buffers any type of vertex they want taking a 2d Point as input for each vertex. The structs VertexBuffers and geometry_buider::BuffersBuilder are provided for convenience. VertexBuffers<T> is contains a Vec<T> for the vertices and a Vec<u16> for the indices.

BuffersBuilder is generic over a VertexConstructor<InputVertex, OutputVertex> trait which creates the application's output vertices from the tessellator input vertices (either FillVertex or StrokeVertex).

Examples

Reexports

pub use core::*;

Modules

basic_shapes

Tessellation routines for simple shapes.

geometry_builder

Structs

BuffersBuilder

A temporary view on a VertexBuffers object which facilitate the population of vertex and index data.

Count

Number of vertices and indices added during the tessellation.

FillEvents

A sequence of edges sorted from top to bottom, to be used as the tessellator's input.

FillOptions

Parameters for the tessellator.

FillTessellator

A Context object that can tessellate fill operations for complex paths.

FillVertex

Vertex produced by the fill tessellators.

StrokeBuilder

A builder that tessellates a stroke directly without allocating any intermediate data structure.

StrokeOptions

Parameters for the tessellator.

StrokeTessellator

A Context object that can tessellate stroke operations for complex paths.

StrokeVertex

Vertex produced by the stroke tessellators.

VertexBuffers

Structure that holds the vertex and index data.

Enums

FillError

The fill tessellator's error enumeration.

FillRule

The fill rule defines how to determine what is inside and what is outside of the shape.

LineCap

Line cap as defined by the SVG specification.

LineJoin

Line join as defined by the SVG specification.

Side

Traits

BezierGeometryBuilder

An extension to GeometryBuilder that can handle quadratic bézier segments.

GeometryBuilder

An interface separating tessellators and other geometry generation algorithms from the actual vertex construction.

VertexConstructor

A trait specifying how to create vertex values.

Functions

compute_max_radius_segment_angle

Computes the max angle of a radius segment for a given tolerance

is_after

Defines an ordering between two points

Type Definitions

FillResult

The fill tessellator's result type.