Struct Sprite

Source
pub struct Sprite<Bytes: ?Sized = [u8]> {
    pub indices: DrawIndices,
    /* private fields */
}

Fields§

§indices: DrawIndices

Implementations§

Source§

impl<const N: usize> Sprite<[u8; N]>

Source

pub const fn from_byte_array( bytes: [u8; N], shape: [u32; 2], bpp: BitsPerPixel, draw_colors: DrawIndices, ) -> Option<Self>

Create a sprite from an array of bytes and other metadata.

§Errors

Returns None if bytes wont fit the given sprite shape and bpp.

Source§

impl<Bytes> Sprite<Bytes>

Source

pub const unsafe fn from_bytes_unchecked( bytes: Bytes, shape: [u32; 2], bpp: BitsPerPixel, draw_colors: DrawIndices, ) -> Self

Create a sprite from an array of bytes and other metadata without a safety check.

§Safety

Invalidates type’s safety invariant Sprite::from_byte_array would return None. It wont error if safety requirement is violated during const evaluation, instead resulting in undefined behavior when returned object’s methods are called.

Source§

impl<Bytes: AsRef<[u8]>> Sprite<Bytes>

Source

pub fn from_bytes( bytes: Bytes, shape: [u32; 2], bpp: BitsPerPixel, draw_colors: DrawIndices, ) -> Option<Self>

Source§

impl<Bytes: ?Sized> Sprite<Bytes>

Source

pub const fn bytes(&self) -> &Bytes

Get a reference to the sprite’s bytes.

Source

pub const fn shape(&self) -> [u32; 2]

Get the sprite’s shape.

Source

pub const fn width(&self) -> u32

Get the sprite’s width.

Source

pub const fn height(&self) -> u32

Get the sprite’s height.

Source

pub const fn bpp(&self) -> BitsPerPixel

Get the sprite’s bpp (bits per pixel).

Source§

impl Sprite

Source

pub const fn view( &self, start: [u32; 2], shape: [u32; 2], ) -> Option<SpriteView<'_>>

Create a subview to the sprite. Returns None if subview is out of bounds of the sprite.

Source

pub const unsafe fn view_unchecked( &self, start: [u32; 2], shape: [u32; 2], ) -> SpriteView<'_>

Create a subview to the sprite. Does not perform in bounds checks.

§Safety

Resulting subview should be inside of the bounds of the Sprite

Trait Implementations§

Source§

impl<Bytes: Clone + ?Sized> Clone for Sprite<Bytes>

Source§

fn clone(&self) -> Sprite<Bytes>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Bytes: Copy + ?Sized> Copy for Sprite<Bytes>

Auto Trait Implementations§

§

impl<Bytes> Freeze for Sprite<Bytes>
where Bytes: Freeze + ?Sized,

§

impl<Bytes> RefUnwindSafe for Sprite<Bytes>
where Bytes: RefUnwindSafe + ?Sized,

§

impl<Bytes> Send for Sprite<Bytes>
where Bytes: Send + ?Sized,

§

impl<Bytes> Sync for Sprite<Bytes>
where Bytes: Sync + ?Sized,

§

impl<Bytes> Unpin for Sprite<Bytes>
where Bytes: Unpin + ?Sized,

§

impl<Bytes> UnwindSafe for Sprite<Bytes>
where Bytes: UnwindSafe + ?Sized,

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