#[non_exhaustive]pub struct Sprite {
pub pixels: Vec<u8>,
pub pixel_width: u32,
pub pixel_height: u32,
pub align: SpriteAlign,
pub color: SheetColor,
}Expand description
A decoded, ready-to-blit sprite.
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.pixels: Vec<u8>RGBA8 pixel data, row-major, pixel_width * pixel_height * 4 bytes.
pixel_width: u32Pixel width of the sprite.
pixel_height: u32Pixel height of the sprite.
align: SpriteAlignWhere this sprite sits inside the multi-cell box a span reserves for it.
color: SheetColorWhat this sprite’s own sheet declared its pixels to mean.
Copied from the sheet at load time rather than looked up at draw time: a SpriteCache is
a flat map keyed by codepoint, so a sprite loses track of which sheet it came from the
moment it lands there. One byte per sprite keeps the sheet’s declaration with the pixels
it describes.
Implementations§
Source§impl Sprite
impl Sprite
Sourcepub const fn align_offset(
&self,
span_w: u16,
span_h: u16,
glyph_w: u8,
glyph_h: u8,
) -> (i16, i16)
pub const fn align_offset( &self, span_w: u16, span_h: u16, glyph_w: u8, glyph_h: u8, ) -> (i16, i16)
Returns the offset, in unscaled pixels, from the top-left corner of a span_w x span_h
cell box to where this sprite’s own top-left pixel belongs, per align.
span_w/span_h come from Tile::span and glyph_w/
glyph_h are the unscaled cell size, so the box is span_w * glyph_w x
span_h * glyph_h pixels. A zero cell size is treated as one pixel, leaving the sprite on
its anchor rather than offsetting it by a meaningless amount.
Returns (0, 0) whenever the art already fills its box, which is the common case, so a
backend can add the result to a tile’s
dx/dy unconditionally.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sprite
impl RefUnwindSafe for Sprite
impl Send for Sprite
impl Sync for Sprite
impl Unpin for Sprite
impl UnsafeUnpin for Sprite
impl UnwindSafe for Sprite
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.