Skip to main content

TiledPattern

Struct TiledPattern 

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

A pre-rasterised tiling pattern.

The tile is a row-major RGB8 pixel buffer of width × height pixels, anchored at (phase_x, phase_y) in device space. fill_span tiles the buffer by wrapping coordinates with rem_euclid.

§Invariants

  • width > 0 and height > 0 (asserted in TiledPattern::new)
  • pixels.len() == width * height * 3

Implementations§

Source§

impl TiledPattern

Source

pub fn new( pixels: Vec<u8>, width: i32, height: i32, phase_x: i32, phase_y: i32, ) -> Self

Construct a new TiledPattern.

§Panics

Panics if width or height is ≤ 0, or if pixels.len() does not equal width * height * 3.

Trait Implementations§

Source§

impl Pattern for TiledPattern

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

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.