Enum SpriteMipLevel

Source
pub enum SpriteMipLevel {
    SingleChunkSprite {
        offset: (u16, u16),
        size: (u16, u16),
        sprite_chunk: u32,
    },
    MultiChunkSprite {
        size: (u16, u16),
        sprite_chunks: Range<u32>,
    },
}
Expand description

One mipmap level (i.e. a sprite with a specific resolution) of a SpriteAsset.

Each SpriteAsset has a maximum of MAX_MIPS of these, with the first level being the resolution of the original sprite, and each successive mip having half the width and height of the previous mip.

The sprites do not use hardware mipmapping. Multiple mip levels (especially the smaller ones) can share a single sprite chunk.

Variants§

§

SingleChunkSprite

A sprite contained within a single chunk. Unlike the other variant, these sprite might not be located in the top-left corner of the chunk, so this variant has an offset field.

Fields

§offset: (u16, u16)

Offset from the topmost and leftmost chunks where the actual sprite starts.

§size: (u16, u16)

The dimensions of the sprite in pixels.

§sprite_chunk: u32

The chunk the sprite’s pixels are located in. The subregion to render is described by the offset and size fields.

§

MultiChunkSprite

A sprite split between multiple sprite chunks.

Chunks are allocated for a multi-chunk sprite starting from the top-left, row by row. Each chunk has a 1px border (copied from the edge of the sprite, creating a kind of clamp-to-edge effect), inside which is the actual sprite. The chunks on the right and bottom edges of the sprite are the only ones that don’t occupy their sprite chunk entirely, they instead occupy only up to the sprite’s width and height plus the border, effectively taking up a width + 2 by `height

  • 2` region from the top left corner of those chunks due to the border.

Fields

§size: (u16, u16)

The dimensions of the sprite in pixels.

§sprite_chunks: Range<u32>

The chunks the sprite is made up of.

Trait Implementations§

Source§

impl Debug for SpriteMipLevel

Source§

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

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

impl Deserialize for SpriteMipLevel

Source§

const SERIALIZED_SIZE: usize = 13usize

The length of the buffer passed into Deserialize::deserialize.
Source§

fn deserialize(src: &[u8]) -> Self

Deserializes the byte buffer into the struct. The length of src must match the same type’s Deserialize::SERIALIZED_SIZE constant.
Source§

impl Serialize for SpriteMipLevel

Source§

const SERIALIZED_SIZE: usize = 13usize

The length of the buffer passed into Serialize::serialize.
Source§

fn serialize(&self, dst: &mut [u8])

Serializes the struct into the byte buffer. The length of dst must match the same type’s Serialize::SERIALIZED_SIZE constant.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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