pub trait Texture {
    type Pixel: Pixel;

    // Required methods
    fn width(&self) -> u32;
    fn height(&self) -> u32;
    fn get(&self, x: u32, y: u32) -> Option<Self::Pixel>;
    fn set(&mut self, x: u32, y: u32, val: Self::Pixel);

    // Provided methods
    fn get_rotated(&self, x: u32, y: u32) -> Option<Self::Pixel> { ... }
    fn is_column_transparent(&self, col: u32) -> bool { ... }
    fn is_row_transparent(&self, row: u32) -> bool { ... }
}
Expand description

Describes a texture type.

Required Associated Types§

source

type Pixel: Pixel

Pixel type of this texture.

Required Methods§

source

fn width(&self) -> u32

Get the width of this texture.

source

fn height(&self) -> u32

Get the height of this texture.

source

fn get(&self, x: u32, y: u32) -> Option<Self::Pixel>

Get the pixel value at a specific coordinate.

source

fn set(&mut self, x: u32, y: u32, val: Self::Pixel)

Set the pixel value at a specific coordinate.

Provided Methods§

source

fn get_rotated(&self, x: u32, y: u32) -> Option<Self::Pixel>

Get the pixel if it were transformed by a rotation.

source

fn is_column_transparent(&self, col: u32) -> bool

Check if a column of the texture is transparent.

source

fn is_row_transparent(&self, row: u32) -> bool

Check if a row of the texture is transparent.

Trait Implementations§

source§

impl<P: Pixel> Texture for Box<dyn Texture<Pixel = P> + 'static>

§

type Pixel = P

Pixel type of this texture.
source§

fn width(&self) -> u32

Get the width of this texture.
source§

fn height(&self) -> u32

Get the height of this texture.
source§

fn get(&self, x: u32, y: u32) -> Option<P>

Get the pixel value at a specific coordinate.
source§

fn set(&mut self, x: u32, y: u32, val: P)

Set the pixel value at a specific coordinate.
source§

fn get_rotated(&self, x: u32, y: u32) -> Option<Self::Pixel>

Get the pixel if it were transformed by a rotation.
source§

fn is_column_transparent(&self, col: u32) -> bool

Check if a column of the texture is transparent.
source§

fn is_row_transparent(&self, row: u32) -> bool

Check if a row of the texture is transparent.

Implementations on Foreign Types§

source§

impl<P: Pixel> Texture for Box<dyn Texture<Pixel = P> + 'static>

§

type Pixel = P

source§

fn width(&self) -> u32

source§

fn height(&self) -> u32

source§

fn get(&self, x: u32, y: u32) -> Option<P>

source§

fn set(&mut self, x: u32, y: u32, val: P)

Implementors§

source§

impl Texture for MemoryRGBA8Texture

§

type Pixel = RGBA8

source§

impl<'a, Pix, T, K: Clone + Eq + Hash> Texture for TexturePacker<'a, T, K>
where Pix: Pixel, T: Texture<Pixel = Pix> + Clone,

§

type Pixel = Pix

source§

impl<'a, T: Texture + Clone> Texture for SubTexture<'a, T>

§

type Pixel = <T as Texture>::Pixel

source§

impl<P: Pixel + Pixel, I: GenericImage<Pixel = P>> Texture for I