Skip to main content

RasterizerCellsAa

Struct RasterizerCellsAa 

Source
pub struct RasterizerCellsAa { /* private fields */ }
Expand description

The main rasterization engine that converts line segments (edges) into anti-aliased pixel cells.

Port of C++ rasterizer_cells_aa<Cell> from agg_rasterizer_cells_aa.h.

Instead of the C++ block-based allocator, we use a flat Vec<CellAa>. Sorted cell access uses indices into this vec rather than raw pointers.

Implementations§

Source§

impl RasterizerCellsAa

Source

pub fn new() -> Self

Create a new empty cell rasterizer.

Source

pub fn reset(&mut self)

Reset the rasterizer, discarding all cells.

Source

pub fn style(&mut self, style_cell: &CellAa)

Set the current style cell (used by compound rasterizer; no-op for basic usage).

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 total_cells(&self) -> u32

Total number of accumulated cells.

Source

pub fn sorted(&self) -> bool

Whether cells have been sorted.

Source

pub fn scanline_num_cells(&self, y: u32) -> u32

Number of cells on scanline y (only valid after sort_cells()).

Source

pub fn scanline_cells(&self, y: u32) -> &[u32]

Get a slice of cell indices for scanline y (only valid after sort_cells()). Returns indices into the internal cells array.

Source

pub fn cell(&self, idx: u32) -> &CellAa

Get a reference to the cell at the given index.

Source

pub fn cells(&self) -> &[CellAa]

Get a reference to all cells.

Source

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

Add a line segment in 24.8 fixed-point coordinates.

This is the primary entry point for the rasterizer. Large dx values are handled by recursive subdivision (matching the C++ implementation).

Source

pub fn sort_cells(&mut self)

Sort all accumulated cells by Y then X.

After sorting, cells can be queried per-scanline via scanline_num_cells() and scanline_cells().

Trait Implementations§

Source§

impl Default for RasterizerCellsAa

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.