Struct lyon_tessellation::FillTessellator [] [src]

pub struct FillTessellator { /* fields omitted */ }

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

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 GeometryBuilder (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();

{
    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(),
        &FillOptions::default(),
        &mut vertex_builder
    );
    assert!(result.is_ok());
}

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

Limitations

The fill tessellator internally works with 16.16 fixed point numbers. This means that it is unable to represent numbers with absolute values larger than 32767.0 without running into overflows and undefined behavior.

How the fill tessellator works

Learn more about how the algrorithm works on the tessellator wiki page.

Methods

impl FillTessellator
[src]

[src]

Constructor.

[src]

Compute the tessellation from a path iterator.

[src]

Compute the tessellation from pre-sorted events.

[src]

Enable some verbose logging during the tessellation, for debugging purposes.

Trait Implementations

Auto Trait Implementations