Struct simple_tilemap::Tile

source ·
pub struct Tile<U = ()> {
    pub id: TileId,
    pub color: Color,
    pub opts: BlitOptions,
    pub data: U,
}
Expand description

Tile in a Tilemap.

Fields§

§id: TileId

Id of the tile.

§color: Color

Color of the tile. Will be multiplied by the tile’s ‘original’ color (the one in the tileset).

§opts: BlitOptions

Blit options.

§data: U

Custom user data.

Implementations§

source§

impl<U> Tile<U>
where U: Default,

source

pub fn new(id: TileId) -> Self

Contruct a new tile.

source§

impl<U> Tile<U>

source

pub fn with_color(self, color: Color) -> Self

Set tile color.

Allows for chaining tile creation like Tile::new(4).with_color(Color::new(255, 0, 255, 255)).solid() etc.

source

pub fn set_color(&mut self, color: Color) -> &mut Self

Set tile color.

Allows for chaining tile modifying like tilemap.get_mut_tile(1, 1).unwrap().set_color(Color::new(255, 0, 255, 255)) etc.

source

pub fn with_user_data(self, data: U) -> Self

Set tile user data.

Allows for chaining tile creation like Tile::new(4).with_color(Color::new(255, 0, 255, 255)) etc.

source

pub fn set_user_data(&mut self, data: U) -> &mut Self

Set tile user data.

Allows for chaining tile modifying like tilemap.get_mut_tile(1, 1).unwrap().set_color(Color::new(255, 0, 255, 255)) etc.

source

pub fn with_blit_options(self, opts: BlitOptions) -> Self

Specify the blit options.

Allows for chaining tile creation like Tile::new(4).with_color(Color::new(255, 0, 255, 255)) etc.

source

pub fn set_blit_options(&mut self, opts: BlitOptions) -> &mut Self

Set the tile’s blit options.

Allows for chaining tile modifying like tilemap.get_mut_tile(1, 1).unwrap().set_color(Color::new(255, 0, 255, 255)) etc.

Trait Implementations§

source§

impl<C> Buffer<Tile> for Tilemap<C>

source§

fn width(&self) -> u32

Buffer width
source§

fn height(&self) -> u32

Buffer height
source§

fn get(&self, x: u32, y: u32) -> &Tile

Get a value at (x, y). This function must not panic when x < self.width() && y < self.height() (unless you want blit functions to panic). It will not be called with values outside of that range.
source§

impl<C> BufferMut<Tile> for Tilemap<C>

source§

fn get_mut(&mut self, x: u32, y: u32) -> &mut Tile

Get a mutable value at (x, y). This function must not panic when x < self.width() && y < self.height() (unless you want blit functions to panic). It will not be called with values outside of that range.
source§

impl<U: Clone> Clone for Tile<U>

source§

fn clone(&self) -> Tile<U>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<U: Debug> Debug for Tile<U>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<U: Default> Default for Tile<U>

source§

fn default() -> Tile<U>

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

impl<U: PartialEq> PartialEq for Tile<U>

source§

fn eq(&self, other: &Tile<U>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<U: Copy> Copy for Tile<U>

source§

impl<U: Eq> Eq for Tile<U>

source§

impl<U> StructuralEq for Tile<U>

source§

impl<U> StructuralPartialEq for Tile<U>

Auto Trait Implementations§

§

impl<U> RefUnwindSafe for Tile<U>
where U: RefUnwindSafe,

§

impl<U> Send for Tile<U>
where U: Send,

§

impl<U> Sync for Tile<U>
where U: Sync,

§

impl<U> Unpin for Tile<U>
where U: Unpin,

§

impl<U> UnwindSafe for Tile<U>
where U: UnwindSafe,

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.