Skip to main content

ScanlineU8

Struct ScanlineU8 

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

Unpacked scanline container with per-pixel u8 coverage values.

Port of C++ scanline_u8. Each pixel in a span has its own coverage byte, stored in a flat array indexed by x - min_x.

Usage protocol:

  1. reset(min_x, max_x) — allocate covers and spans arrays
  2. add_cell() / add_span() — accumulate span data (X must be monotonically increasing)
  3. finalize(y) — set the Y coordinate
  4. Iterate with begin() and covers() for rendering
  5. reset_spans() — prepare for next scanline

Implementations§

Source§

impl ScanlineU8

Source

pub fn new() -> Self

Source

pub fn reset(&mut self, min_x: i32, max_x: i32)

Prepare for a new scanline with the given X range.

Source

pub fn begin(&self) -> &[ScanlineSpan]

Get the slice of active spans (for renderer iteration). Spans are 1-indexed; index 0 is a sentinel.

Source

pub fn covers(&self) -> &[u8]

Get the full covers array (spans reference into this via cover_offset).

Trait Implementations§

Source§

impl Default for ScanlineU8

Source§

fn default() -> Self

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

impl Scanline for ScanlineU8

Source§

fn reset_spans(&mut self)

Prepare for a new scanline, clearing all span data.
Source§

fn add_cell(&mut self, x: i32, cover: u32)

Add a single cell at position x with coverage cover.
Source§

fn add_span(&mut self, x: i32, len: u32, cover: u32)

Add a horizontal span of len pixels starting at x, all with cover.
Source§

fn finalize(&mut self, y: i32)

Finalize the scanline at the given Y coordinate.
Source§

fn num_spans(&self) -> u32

Number of spans in this scanline (0 means empty).
Source§

fn y(&self) -> i32

The Y coordinate of this scanline.

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.