Skip to main content

RasterizerScanlineAa

Struct RasterizerScanlineAa 

Source
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:

  1. Optionally set filling_rule() and clip_box()
  2. Define contours with move_to_d() / line_to_d() or add_path()
  3. Call rewind_scanlines() then repeatedly sweep_scanline() to extract AA data

Implementations§

Source§

impl RasterizerScanlineAa

Source

pub fn new() -> Self

Source

pub fn reset(&mut self)

Reset the rasterizer, discarding all polygon data.

Source

pub fn filling_rule(&mut self, rule: FillingRule)

Set the filling rule (non-zero winding or even-odd).

Source

pub fn auto_close(&mut self, flag: bool)

Enable or disable automatic polygon closing on move_to.

Source

pub fn clip_box(&mut self, x1: f64, y1: f64, x2: f64, y2: f64)

Set the clipping rectangle in floating-point coordinates.

Source

pub fn reset_clipping(&mut self)

Disable clipping.

Source

pub fn close_polygon(&mut self)

Close the current polygon contour.

Source

pub fn move_to(&mut self, x: i32, y: i32)

Move to a new position in 24.8 fixed-point coordinates.

Source

pub fn line_to(&mut self, x: i32, y: i32)

Line to in 24.8 fixed-point coordinates.

Source

pub fn move_to_d(&mut self, x: f64, y: f64)

Move to a new position in floating-point coordinates.

Source

pub fn line_to_d(&mut self, x: f64, y: f64)

Line to in floating-point coordinates.

Source

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).

Source

pub fn edge(&mut self, x1: i32, y1: i32, x2: i32, y2: i32)

Add a single edge in 24.8 fixed-point coordinates.

Source

pub fn edge_d(&mut self, x1: f64, y1: f64, x2: f64, y2: f64)

Add a single edge in floating-point coordinates.

Source

pub fn add_path(&mut self, vs: &mut dyn VertexSource, path_id: u32)

Add all vertices from a vertex source.

Source

pub fn min_x(&self) -> i32

Source

pub fn min_y(&self) -> i32

Source

pub fn max_x(&self) -> i32

Source

pub fn max_y(&self) -> i32

Source

pub fn rewind_scanlines(&mut self) -> bool

Sort cells and prepare for scanline sweeping. Returns false if there are no cells (nothing to render).

Source

pub fn navigate_scanline(&mut self, y: i32) -> bool

Navigate to a specific scanline Y (for random access).

Source

pub fn sort(&mut self)

Sort cells (explicit sort without starting a sweep).

Source

pub fn calculate_alpha(&self, area: i32) -> u32

Calculate alpha (coverage) from accumulated area.

This is the “nogamma” variant — no gamma LUT, raw coverage.

Source

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.

Source

pub fn hit_test(&mut self, tx: i32, ty: i32) -> bool

Test if a specific pixel coordinate is inside the rasterized polygon.

Trait Implementations§

Source§

impl Default for RasterizerScanlineAa

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.