Struct lyon::tessellation::StrokeTessellator [−][src]
pub struct StrokeTessellator {}
A Context object that can tessellate stroke operations for complex paths.
Overview
The stroke tessellation algorithm simply generates a strip of triangles along the path. This method is fast and simple to implement, howerver it means that if the path overlap with itself (for example in the case of a self-intersecting path), some triangles will overlap in the interesecting region, which may not be the desired behavior. This needs to be kept in mind when rendering transparent SVG strokes since the spec mandates that each point along a semi-transparent path is shaded once no matter how many times the path overlaps with itself at this location.
StrokeTessellator
exposes a similar interface to its
fill equivalent.
This stroke tessellator takes an iterator of path events as inputs as well as
a StrokeOption
, and produces its outputs using
a GeometryBuilder
.
See the geometry_builder
module documentation
for more details about how to output custom vertex layouts.
See https://github.com/nical/lyon/wiki/Stroke-tessellation for some notes about how the path stroke tessellator is implemented.
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<StrokeVertex, u16> = VertexBuffers::new(); { // Create the destination vertex and index buffers. let mut vertex_builder = simple_builder(&mut buffers); // Create the tessellator. let mut tessellator = StrokeTessellator::new(); // Compute the tessellation. tessellator.tessellate_path( path.path_iter(), &StrokeOptions::default(), &mut vertex_builder ); } println!("The generated vertices are: {:?}.", &buffers.vertices[..]); println!("The generated indices are: {:?}.", &buffers.indices[..]);
Methods
impl StrokeTessellator
[src]
impl StrokeTessellator
pub fn new() -> StrokeTessellator
[src]
pub fn new() -> StrokeTessellator
pub fn tessellate_path<Input>(
&mut self,
input: Input,
options: &StrokeOptions,
builder: &mut GeometryBuilder<StrokeVertex>
) -> Count where
Input: PathIterator,
[src]
pub fn tessellate_path<Input>(
&mut self,
input: Input,
options: &StrokeOptions,
builder: &mut GeometryBuilder<StrokeVertex>
) -> Count where
Input: PathIterator,
Compute the tessellation from a path iterator.
Trait Implementations
impl Default for StrokeTessellator
[src]
impl Default for StrokeTessellator
fn default() -> StrokeTessellator
[src]
fn default() -> StrokeTessellator
Returns the "default value" for a type. Read more
Auto Trait Implementations
impl Send for StrokeTessellator
impl Send for StrokeTessellator
impl Sync for StrokeTessellator
impl Sync for StrokeTessellator