pub struct SpriteSheet { /* private fields */ }Expand description
Defines a sprite sheet with uniform frame grid dimensions.
Implementations§
Source§impl SpriteSheet
Implements frame extraction, rendering, and animation creation for SpriteSheet.
impl SpriteSheet
Implements frame extraction, rendering, and animation creation for SpriteSheet.
Sourcepub fn from_image(
image: HtmlImageElement,
frame_width: f64,
frame_height: f64,
) -> SpriteSheet
pub fn from_image( image: HtmlImageElement, frame_width: f64, frame_height: f64, ) -> SpriteSheet
Creates a new sprite sheet from an image element and uniform frame dimensions.
Computes the grid columns and rows from the image dimensions and frame size.
§Arguments
HtmlImageElement- The sprite sheet image.f64- The width of each frame.f64- The height of each frame.
§Returns
SpriteSheet- The new sprite sheet.
Sourcepub fn frame_source(&self, index: u32) -> Rect
pub fn frame_source(&self, index: u32) -> Rect
Sourcepub fn frame(&self, index: u32) -> SpriteFrame
pub fn frame(&self, index: u32) -> SpriteFrame
Sourcepub fn animation(
&self,
name: &str,
start: u32,
end: u32,
mode: AnimationMode,
) -> SpriteAnimation
pub fn animation( &self, name: &str, start: u32, end: u32, mode: AnimationMode, ) -> SpriteAnimation
Sourcepub fn draw_frame(
&self,
context: &CanvasRenderingContext2d,
frame_index: u32,
transform: &Transform2D,
)
pub fn draw_frame( &self, context: &CanvasRenderingContext2d, frame_index: u32, transform: &Transform2D, )
Draws a static (non-animated) sprite frame onto the canvas.
§Arguments
&CanvasRenderingContext2d- The canvas context.u32- The frame index to draw.&Transform2D- The world-space transform to apply.
Source§impl SpriteSheet
impl SpriteSheet
pub fn get_image(&self) -> &HtmlImageElement
pub fn get_mut_image(&mut self) -> &mut HtmlImageElement
pub fn set_image(&mut self, val: HtmlImageElement) -> &mut Self
pub fn get_frame_width(&self) -> f64
pub fn get_mut_frame_width(&mut self) -> &mut f64
pub fn set_frame_width(&mut self, val: f64) -> &mut Self
pub fn get_frame_height(&self) -> f64
pub fn get_mut_frame_height(&mut self) -> &mut f64
pub fn set_frame_height(&mut self, val: f64) -> &mut Self
Source§impl SpriteSheet
impl SpriteSheet
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 moreSource§impl Debug for SpriteSheet
impl Debug for SpriteSheet
Source§impl PartialEq for SpriteSheet
impl PartialEq for SpriteSheet
Source§fn eq(&self, other: &SpriteSheet) -> bool
fn eq(&self, other: &SpriteSheet) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for SpriteSheet
Auto 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