Skip to main content

Pattern

Trait Pattern 

Source
pub trait Pattern: Send + Sync {
    // Required method
    fn fill_span(&self, y: i32, x0: i32, x1: i32, out: &mut [u8]);

    // Provided method
    fn is_static_color(&self) -> bool { ... }
}
Expand description

A source of per-pixel colour for use with the compositing pipeline.

Implementors return raw device-space byte sequences into the provided buffer. The buffer length is (x1 - x0 + 1) * ncomps where ncomps is the pixel size for the target bitmap mode.

Required Methods§

Source

fn fill_span(&self, y: i32, x0: i32, x1: i32, out: &mut [u8])

Fill out with colour bytes for pixels x0..=x1 on scanline y.

out.len() is guaranteed to be (x1 - x0 + 1) * ncomps.

Provided Methods§

Source

fn is_static_color(&self) -> bool

Return true if this pattern yields the same colour at every coordinate. When true, fill_span will be called once and the result reused across the whole span (optimisation hint only — correctness is not affected).

Implementors§