#[non_exhaustive]pub struct TilesetOptions {
pub bytes: Vec<u8>,
pub tile_width: u16,
pub tile_height: u16,
pub columns: Option<u16>,
pub codepage: Codepage,
pub align: SpriteAlign,
pub color: SheetColor,
pub transparent_color: Option<(u8, u8, u8)>,
}Expand description
Options for loading a single tileset (sprite sheet).
§Sprites carry their own color
By default (SheetColor::Art) a tileset’s artwork is composited verbatim: the cell’s
Style::fg does not tint it, so a full-color sheet renders
exactly as authored. The cell’s background is still painted behind the sprite and shows
through its transparent pixels.
A sheet authored as white-on-transparent masks declares SheetColor::Mask instead, and its
sprites are colored by the cell’s foreground the way a bitmap font glyph is.
Recoloring one piece of artwork per cell (biome variants, damage flashes) is a per-draw
decision rather than a sheet-wide one, and goes through
Surface::with_tint.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.bytes: Vec<u8>Raw bytes of the sprite sheet image (any format the image crate supports).
tile_width: u16Width of a single tile in pixels.
tile_height: u16Height of a single tile in pixels.
columns: Option<u16>Number of tiles per row in the sprite sheet.
If None, derived as image_width / tile_width.
codepage: CodepageCodepoint mapping from tile index to Unicode character.
align: SpriteAlignWhere each sprite sits inside the multi-cell box a span reserves for it.
color: SheetColorWhat this sheet’s pixels mean, and so whether the cell’s foreground color colors them.
transparent_color: Option<(u8, u8, u8)>If set, any pixel matching this RGB colour is made fully transparent (alpha = 0) when decoding the tileset.
Useful for spritesheets that use a solid colour background instead
of an alpha channel. Equivalent to bracket-lib’s with_font_bg()
or doryen-rs’s top-left-pixel key colour auto-detection.
Implementations§
Source§impl TilesetOptions
impl TilesetOptions
Sourcepub const fn builder(bytes: Vec<u8>) -> TilesetBuilder
pub const fn builder(bytes: Vec<u8>) -> TilesetBuilder
Starts building a tileset from raw sprite sheet bytes.
Pass include_bytes!("...").to_vec() to embed the asset at compile
time, or std::fs::read(path)? to load it at runtime.
Trait Implementations§
Source§impl Clone for TilesetOptions
impl Clone for TilesetOptions
Source§fn clone(&self) -> TilesetOptions
fn clone(&self) -> TilesetOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TilesetOptions
impl Debug for TilesetOptions
Source§impl PartialEq for TilesetOptions
impl PartialEq for TilesetOptions
Source§fn eq(&self, other: &TilesetOptions) -> bool
fn eq(&self, other: &TilesetOptions) -> bool
self and other values to be equal, and is used by ==.impl Eq for TilesetOptions
impl StructuralPartialEq for TilesetOptions
Auto Trait Implementations§
impl Freeze for TilesetOptions
impl RefUnwindSafe for TilesetOptions
impl Send for TilesetOptions
impl Sync for TilesetOptions
impl Unpin for TilesetOptions
impl UnsafeUnpin for TilesetOptions
impl UnwindSafe for TilesetOptions
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.