Surface

Trait Surface 

Source
pub trait Surface {
    type Texel;

    // Required methods
    fn texel(&self, x: u32, y: u32) -> Option<Self::Texel>;
    fn set_texel(&mut self, x: u32, y: u32, value: Self::Texel);
    fn clear(&mut self, value: Self::Texel);
    fn width(&self) -> u32;
    fn height(&self) -> u32;

    // Provided methods
    unsafe fn texel_unchecked(&self, x: u32, y: u32) -> Self::Texel { ... }
    unsafe fn set_texel_unchecked(&mut self, x: u32, y: u32, value: Self::Texel) { ... }
}
Expand description

So-so display surface trait for reuse purposes.

Required Associated Types§

Source

type Texel

Specific texel type.

Required Methods§

Source

fn texel(&self, x: u32, y: u32) -> Option<Self::Texel>

Get texel given its coordinates.

Source

fn set_texel(&mut self, x: u32, y: u32, value: Self::Texel)

Set texel given its coordinates.

Source

fn clear(&mut self, value: Self::Texel)

Clear the surface with the given color.

Source

fn width(&self) -> u32

Get surface width.

Source

fn height(&self) -> u32

Get surface height.

Provided Methods§

Source

unsafe fn texel_unchecked(&self, x: u32, y: u32) -> Self::Texel

Get texel given its coordinates unsafely.

§Safety
  • x must be in range [0, width - 1];
  • y must be in range [0, height - 1];
Source

unsafe fn set_texel_unchecked(&mut self, x: u32, y: u32, value: Self::Texel)

Set texel value given its coordinates unsafely.

§Safety
  • x must be in range [0, width - 1];
  • y must be in range [0, height - 1];

Implementors§