[][src]Struct lyon_tessellation::FillTessellator

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, u16> = 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.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 algorithm works on the tessellator wiki page.

Methods

impl FillTessellator[src]

pub fn new() -> Self[src]

Constructor.

pub fn tessellate_path<Iter>(
    &mut self,
    it: Iter,
    options: &FillOptions,
    output: &mut dyn GeometryBuilder<Vertex>
) -> TessellationResult where
    Iter: IntoIterator<Item = PathEvent>, 
[src]

Compute the tessellation from a path iterator.

pub fn tessellate_events(
    &mut self,
    events: &FillEvents,
    options: &FillOptions,
    output: &mut dyn GeometryBuilder<Vertex>
) -> TessellationResult
[src]

Compute the tessellation from pre-sorted events.

pub fn enable_logging(&mut self)[src]

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

Trait Implementations

impl Default for FillTessellator[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]