Skip to main content

TilesetOptions

Struct TilesetOptions 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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: u16

Width of a single tile in pixels.

§tile_height: u16

Height 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: Codepage

Codepoint mapping from tile index to Unicode character.

§align: SpriteAlign

Where each sprite sits inside the multi-cell box a span reserves for it.

§color: SheetColor

What 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

Source

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

Source§

fn clone(&self) -> TilesetOptions

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 TilesetOptions

Source§

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

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

impl PartialEq for TilesetOptions

Source§

fn eq(&self, other: &TilesetOptions) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for TilesetOptions

Source§

impl StructuralPartialEq for TilesetOptions

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

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

§

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

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

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

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

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

§

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.

§

impl<T> Instrument for T

§

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

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

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

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

§

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

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,