pub struct RasterizerScanlineAa { /* private fields */ }Expand description
High-level polygon rasterizer with anti-aliased output.
Port of C++ rasterizer_scanline_aa_nogamma<rasterizer_sl_clip_int>.
Usage:
- Optionally set
filling_rule()andclip_box() - Define contours with
move_to_d()/line_to_d()oradd_path() - Call
rewind_scanlines()then repeatedlysweep_scanline()to extract AA data
Implementations§
Source§impl RasterizerScanlineAa
impl RasterizerScanlineAa
pub fn new() -> Self
Sourcepub fn filling_rule(&mut self, rule: FillingRule)
pub fn filling_rule(&mut self, rule: FillingRule)
Set the filling rule (non-zero winding or even-odd).
Sourcepub fn auto_close(&mut self, flag: bool)
pub fn auto_close(&mut self, flag: bool)
Enable or disable automatic polygon closing on move_to.
Sourcepub fn clip_box(&mut self, x1: f64, y1: f64, x2: f64, y2: f64)
pub fn clip_box(&mut self, x1: f64, y1: f64, x2: f64, y2: f64)
Set the clipping rectangle in floating-point coordinates.
Sourcepub fn reset_clipping(&mut self)
pub fn reset_clipping(&mut self)
Disable clipping.
Sourcepub fn close_polygon(&mut self)
pub fn close_polygon(&mut self)
Close the current polygon contour.
Sourcepub fn move_to(&mut self, x: i32, y: i32)
pub fn move_to(&mut self, x: i32, y: i32)
Move to a new position in 24.8 fixed-point coordinates.
Sourcepub fn move_to_d(&mut self, x: f64, y: f64)
pub fn move_to_d(&mut self, x: f64, y: f64)
Move to a new position in floating-point coordinates.
Sourcepub fn add_vertex(&mut self, x: f64, y: f64, cmd: u32)
pub fn add_vertex(&mut self, x: f64, y: f64, cmd: u32)
Add a vertex (dispatches to move_to, line_to, or close based on command).
Sourcepub fn edge(&mut self, x1: i32, y1: i32, x2: i32, y2: i32)
pub fn edge(&mut self, x1: i32, y1: i32, x2: i32, y2: i32)
Add a single edge in 24.8 fixed-point coordinates.
Sourcepub fn edge_d(&mut self, x1: f64, y1: f64, x2: f64, y2: f64)
pub fn edge_d(&mut self, x1: f64, y1: f64, x2: f64, y2: f64)
Add a single edge in floating-point coordinates.
Sourcepub fn add_path(&mut self, vs: &mut dyn VertexSource, path_id: u32)
pub fn add_path(&mut self, vs: &mut dyn VertexSource, path_id: u32)
Add all vertices from a vertex source.
pub fn min_x(&self) -> i32
pub fn min_y(&self) -> i32
pub fn max_x(&self) -> i32
pub fn max_y(&self) -> i32
Sourcepub fn rewind_scanlines(&mut self) -> bool
pub fn rewind_scanlines(&mut self) -> bool
Sort cells and prepare for scanline sweeping.
Returns false if there are no cells (nothing to render).
Navigate to a specific scanline Y (for random access).
Sourcepub fn calculate_alpha(&self, area: i32) -> u32
pub fn calculate_alpha(&self, area: i32) -> u32
Calculate alpha (coverage) from accumulated area.
This is the “nogamma” variant — no gamma LUT, raw coverage.
Sourcepub fn sweep_scanline<SL: Scanline>(&mut self, sl: &mut SL) -> bool
pub fn sweep_scanline<SL: Scanline>(&mut self, sl: &mut SL) -> bool
Extract the next scanline of anti-aliased coverage data.
This is THE CORE function of the rasterizer. It iterates sorted cells for the current scanline Y, accumulates coverage, and feeds spans to the scanline object.
Returns false when all scanlines have been consumed.