pub struct Tessellator { /* private fields */ }Expand description
Turns paths into GPU-ready triangle meshes.
The tessellator owns the scratch buffers it needs, so filling a chart with many series does not allocate once per shape: the buffers are reused across calls and only grow when a larger shape shows up.
A tessellator is not thread-safe; each renderer owns one.
Implementations§
Source§impl Tessellator
Inherent implementation of Tessellator.
impl Tessellator
Inherent implementation of Tessellator.
Sourcepub fn with_tolerance(tolerance: f64) -> Self
pub fn with_tolerance(tolerance: f64) -> Self
Returns a tessellator with the given flattening tolerance, in pixels.
A smaller tolerance produces smoother curves at the cost of more vertices.
§Arguments
f64- A 64-bit float (f64).
Sourcepub fn flatten(&mut self, path: &Path) -> &FlatPath
pub fn flatten(&mut self, path: &Path) -> &FlatPath
Flattens the path into contours and returns them.
The returned reference borrows the tessellator’s scratch storage and
stays valid until the next call to Tessellator::flatten.
§Arguments
&Path- Shared reference to aPath.
§Returns
&FlatPath- AFlatPathvalue.
Sourcepub fn fill(&mut self, path: &Path, color: u32) -> SolidMesh
pub fn fill(&mut self, path: &Path, color: u32) -> SolidMesh
Triangulates the path and returns the resulting mesh.
The path is filled according to its FillRule. Holes are detected
automatically: a contour nested inside another contour with the
opposite winding direction is treated as a hole, which is what makes
a doughnut chart’s inner ring disappear.
§Arguments
&Path- Shared reference to aPath.u32- A 32-bit unsigned integer (u32).
§Returns
SolidMesh- ASolidMeshvalue.
Sourcepub fn fill_contours(
&mut self,
contours: &[Contour],
color: u32,
rule: FillRule,
) -> SolidMesh
pub fn fill_contours( &mut self, contours: &[Contour], color: u32, rule: FillRule, ) -> SolidMesh
Sourcepub fn fill_strip(
&mut self,
points: &[Point],
baseline: f32,
color: u32,
) -> SolidMesh
pub fn fill_strip( &mut self, points: &[Point], baseline: f32, color: u32, ) -> SolidMesh
Builds a triangle strip for the region between a polyline and a straight baseline.
This is the hot path for area charts: the shape is a strip by construction, so it needs no triangulation at all, and the whole series becomes a single indexed draw call.
points are the polyline vertices in order; baseline is the
vertical coordinate the area is closed against.
§Arguments
&[Point]- Shared reference to a[Point].f32- A 32-bit float (f32).u32- A 32-bit unsigned integer (u32).
§Returns
SolidMesh- ASolidMeshvalue.
Sourcepub fn stroke(
&mut self,
path: &Path,
style: &StrokeStyle,
color: u32,
) -> SolidMesh
pub fn stroke( &mut self, path: &Path, style: &StrokeStyle, color: u32, ) -> SolidMesh
Expands the path into stroke geometry and returns the mesh.
Every segment becomes a quad, and every join becomes a wedge, so the whole stroke is a single indexed draw call regardless of how many segments it has.
§Arguments
&Path- Shared reference to aPath.&StrokeStyle- Shared reference to aStrokeStyle.u32- A 32-bit unsigned integer (u32).
§Returns
SolidMesh- ASolidMeshvalue.
Sourcepub fn stroke_contours(
&mut self,
contours: &[Contour],
style: &StrokeStyle,
color: u32,
) -> SolidMesh
pub fn stroke_contours( &mut self, contours: &[Contour], style: &StrokeStyle, color: u32, ) -> SolidMesh
Trait Implementations§
Source§impl Clone for Tessellator
impl Clone for Tessellator
Source§impl Debug for Tessellator
impl Debug for Tessellator
Source§impl Default for Tessellator
Default construction for Tessellator.
impl Default for Tessellator
Default construction for Tessellator.
Source§fn default() -> Self
fn default() -> Self
Constructs a default Tessellator value.