pub struct Sprite<Bytes: ?Sized = [u8]> {
pub indices: DrawIndices,
/* private fields */
}
Fields§
§indices: DrawIndices
Implementations§
Source§impl<const N: usize> Sprite<[u8; N]>
impl<const N: usize> Sprite<[u8; N]>
Sourcepub const fn from_byte_array(
bytes: [u8; N],
shape: [u32; 2],
bpp: BitsPerPixel,
draw_colors: DrawIndices,
) -> Option<Self>
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>
impl<Bytes> Sprite<Bytes>
Sourcepub const unsafe fn from_bytes_unchecked(
bytes: Bytes,
shape: [u32; 2],
bpp: BitsPerPixel,
draw_colors: DrawIndices,
) -> Self
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>
impl<Bytes: AsRef<[u8]>> Sprite<Bytes>
pub fn from_bytes( bytes: Bytes, shape: [u32; 2], bpp: BitsPerPixel, draw_colors: DrawIndices, ) -> Option<Self>
Source§impl<Bytes: ?Sized> Sprite<Bytes>
impl<Bytes: ?Sized> Sprite<Bytes>
Sourcepub const fn bpp(&self) -> BitsPerPixel
pub const fn bpp(&self) -> BitsPerPixel
Get the sprite’s bpp (bits per pixel).
Source§impl Sprite
impl Sprite
Sourcepub const fn view(
&self,
start: [u32; 2],
shape: [u32; 2],
) -> Option<SpriteView<'_>>
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.
Sourcepub const unsafe fn view_unchecked(
&self,
start: [u32; 2],
shape: [u32; 2],
) -> SpriteView<'_>
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§
impl<Bytes: Copy + ?Sized> Copy for Sprite<Bytes>
Auto Trait Implementations§
impl<Bytes> Freeze for Sprite<Bytes>
impl<Bytes> RefUnwindSafe for Sprite<Bytes>where
Bytes: RefUnwindSafe + ?Sized,
impl<Bytes> Send for Sprite<Bytes>
impl<Bytes> Sync for Sprite<Bytes>
impl<Bytes> Unpin for Sprite<Bytes>
impl<Bytes> UnwindSafe for Sprite<Bytes>where
Bytes: UnwindSafe + ?Sized,
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
Mutably borrows from an owned value. Read more