Skip to main content

TileSet

Struct TileSet 

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

A set of decoded tiles, indexed by tile number.

Implementations§

Source§

impl TileSet

Source

pub fn from_2bpp(data: &[u8]) -> Self

Create a tileset by decoding 2bpp tile data. The data length must be a multiple of 16 (bytes per tile).

Source

pub fn blank(count: usize) -> Self

Create an empty tileset with count blank tiles.

Source

pub fn get(&self, index: usize) -> &Tile

Get a tile by index. Returns blank tile if out of bounds.

Source

pub fn len(&self) -> usize

Number of tiles in this set.

Source

pub fn is_empty(&self) -> bool

Whether this tileset is empty.

Source

pub fn set(&mut self, index: usize, tile: Tile)

Replace a tile at the given index.

Source

pub fn load_2bpp_at(&mut self, start_tile: usize, data: &[u8])

Load raw 2bpp data into the tileset starting at tile index start_tile. Overwrites existing tiles.

Source

pub fn from_1bpp(data: &[u8]) -> Self

Decode 1bpp tile data (8 bytes per tile, 1 bit per pixel). Color 0 → palette index 0, color 1 → palette index 3 (black).

Source

pub fn from_4bpp(data: &[u8]) -> Self

Decode GBA-style 4bpp tile data (32 bytes per tile, 2 bitplanes × 16 bytes each).

Each tile requires 32 bytes. The first 16 bytes are bitplane 0, the next 16 bytes are bitplane 1. Each bitplane uses standard 2bpp encoding (2 bytes per row, low byte then high byte), contributing 2 bits per pixel. Combined they give 4 bits per pixel (0–15), stored in Tile::pixels as u8.

Source

pub fn from_rgba(pixels: &[Rgba], tile_count: usize) -> Self

Create a tileset from flat RGBA pixel data.

pixels should contain tile_count * 64 RGBA values (8×8 pixels per tile). Tiles are laid out sequentially: pixels[0..64] = tile 0, pixels[64..128] = tile 1, etc. Each tile is stored as an RgbaTile in the internal rgba_tiles buffer for direct rendering. The tiles field contains blank dummy tiles for backward compatibility.

Source

pub fn tile_format(&self) -> TileFormat

Return the tile format of this tileset.

Source

pub fn get_rgba(&self, index: usize) -> Option<&RgbaTile>

Get an RGBA tile by index. Returns None if the tileset is not in TileFormat::FullColor mode or the index is out of bounds.

Trait Implementations§

Source§

impl Clone for TileSet

Source§

fn clone(&self) -> TileSet

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TileSet

Source§

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

Formats the value using the given formatter. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more