pub struct SpriteSheet {
pub image: AssetHandle<ImageAsset>,
pub columns: u32,
pub rows: u32,
pub frame_width: f32,
pub frame_height: f32,
}Expand description
A sprite sheet splits a texture into a grid of frames.
Fields§
§image: AssetHandle<ImageAsset>Handle to the source image.
columns: u32Number of columns in the sheet.
rows: u32Number of rows in the sheet.
frame_width: f32Individual frame dimensions (computed).
frame_height: f32Implementations§
Source§impl SpriteSheet
impl SpriteSheet
Sourcepub fn new(image: AssetHandle<ImageAsset>, columns: u32, rows: u32) -> Self
pub fn new(image: AssetHandle<ImageAsset>, columns: u32, rows: u32) -> Self
Create a sprite sheet from an image handle and grid dimensions.
Sourcepub fn frame_rect(&self, index: u32) -> Rect
pub fn frame_rect(&self, index: u32) -> Rect
Get the source rectangle for a specific frame.
Sourcepub fn cell_rect(&self, row: u32, col: u32) -> Rect
pub fn cell_rect(&self, row: u32, col: u32) -> Rect
Get the source rectangle for a specific (row, column).
Sourcepub fn frame_count(&self) -> u32
pub fn frame_count(&self) -> u32
Total number of frames.
Trait Implementations§
Source§impl Clone for SpriteSheet
impl Clone for SpriteSheet
Source§fn clone(&self) -> SpriteSheet
fn clone(&self) -> SpriteSheet
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SpriteSheet
impl RefUnwindSafe for SpriteSheet
impl Send for SpriteSheet
impl Sync for SpriteSheet
impl Unpin for SpriteSheet
impl UnsafeUnpin for SpriteSheet
impl UnwindSafe for SpriteSheet
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