Module lyon_tessellation::path_fill [] [src]

Path fill tessellator

Tessellation routines for complex path fill operations.

Overview

The most important structure is FillTessellator. It implements the path fill tessellation algorithm which is by far the most advanced feature in all lyon crates.

The FillTessellator takes a FillEvents object and FillOptions as input. The former is an intermediate representaion of the path, containing all edges sorted from top to bottom. FillOption contains some extra parameters (Some of which are not implemented yet).

The output of the tessellator is produced by the BezierGeometryBuilder (see the geometry_builder documentation for more details about how tessellators produce their output geometry, and how to generate custom vertex layouts).

The tessellator's wiki page is a good place to learn more about how the tessellator's algorithm works. The source code also contains inline documentation for the adventurous who want to delve into more details.

Examples

// Create a simple path.
let mut path_builder = Path::builder();
path_builder.move_to(point(0.0, 0.0));
path_builder.line_to(point(1.0, 2.0));
path_builder.line_to(point(2.0, 0.0));
path_builder.line_to(point(1.0, 1.0));
path_builder.close();
let path = path_builder.build();

// Create the destination vertex and index buffers.
let mut buffers: VertexBuffers<FillVertex> = VertexBuffers::new();

{
    // Create the destination vertex and index buffers.
    let mut vertex_builder = simple_builder(&mut buffers);

    // Create the tessellator.
    let mut tessellator = FillTessellator::new();

    // Compute the tessellation.
    let result = tessellator.tessellate_path(
        path.path_iter().flattened(0.05),
        &FillOptions::default(),
        &mut vertex_builder
    );
    assert!(result.is_ok());
}

println!("The generated vertices are: {:?}.", &buffers.vertices[..]);
println!("The generated indices are: {:?}.", &buffers.indices[..]);

Structs

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.

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.

Functions

is_after

Defines an ordering between two points

Type Definitions

FillResult

The fill tessellator's result type.