Struct lyon_tessellation::FillTessellator
[−]
[src]
pub struct FillTessellator { pub _handle_intersections: bool, // some 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(); { // 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_flattened_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[..]);
How the fill tessellator works
Learn more about how the algrorithm works on the tessellator wiki page.
Fields
_handle_intersections: bool
Methods
impl FillTessellator
[src]
fn new() -> FillTessellator
Constructor.
fn tessellate_path<Iter, Output>(
&mut self,
it: Iter,
options: &FillOptions,
output: &mut Output
) -> FillResult where
Iter: PathIterator,
Output: GeometryBuilder<Vertex>,
&mut self,
it: Iter,
options: &FillOptions,
output: &mut Output
) -> FillResult where
Iter: PathIterator,
Output: GeometryBuilder<Vertex>,
Compute the tessellation from a path iterator.
fn tessellate_flattened_path<Iter, Output>(
&mut self,
it: Iter,
options: &FillOptions,
output: &mut Output
) -> FillResult where
Iter: Iterator<Item = FlattenedEvent>,
Output: GeometryBuilder<Vertex>,
&mut self,
it: Iter,
options: &FillOptions,
output: &mut Output
) -> FillResult where
Iter: Iterator<Item = FlattenedEvent>,
Output: GeometryBuilder<Vertex>,
Compute the tessellation from a flattened path iterator.
fn tessellate_events<Output>(
&mut self,
events: &FillEvents,
options: &FillOptions,
output: &mut Output
) -> FillResult where
Output: GeometryBuilder<Vertex>,
&mut self,
events: &FillEvents,
options: &FillOptions,
output: &mut Output
) -> FillResult where
Output: GeometryBuilder<Vertex>,
Compute the tessellation from pre-sorted events.
fn enable_logging(&mut self)
Enable some verbose logging during the tessellation, for debugging purposes.