pub struct TileSet { /* private fields */ }Expand description
A set of decoded tiles, indexed by tile number.
Implementations§
Source§impl TileSet
impl TileSet
Sourcepub fn from_2bpp(data: &[u8]) -> Self
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).
Sourcepub fn get(&self, index: usize) -> &Tile
pub fn get(&self, index: usize) -> &Tile
Get a tile by index. Returns blank tile if out of bounds.
Sourcepub fn load_2bpp_at(&mut self, start_tile: usize, data: &[u8])
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.
Sourcepub fn from_1bpp(data: &[u8]) -> Self
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).
Sourcepub fn from_4bpp(data: &[u8]) -> Self
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.
Sourcepub fn from_rgba(pixels: &[Rgba], tile_count: usize) -> Self
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.
Sourcepub fn tile_format(&self) -> TileFormat
pub fn tile_format(&self) -> TileFormat
Return the tile format of this tileset.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TileSet
impl RefUnwindSafe for TileSet
impl Send for TileSet
impl Sync for TileSet
impl Unpin for TileSet
impl UnsafeUnpin for TileSet
impl UnwindSafe for TileSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.