pub struct SpriteViewImpl<'a> { /* private fields */ }Expand description
A view of a modified sprite
A sprite view can be used to apply transformations to a sprite before drawing it to screen.
use wasm4fun_graphics::{Rotation, Sprite};
let sprite: Sprite = unimplemented!();
let clipped = sprite.clip(30, 10, 80, 20);
let rotated = sprite.rotate(Rotation::Rotate90);
let clipped_and_rotated = clipped.rotate(Rotation::Rotate90);
rotated.blit(0, 0);
clipped_and_rotated.blit(50, 50);§Order of Operations
When applying both flipping and rotation, flipping is performed first.
Implementations§
Source§impl<'a> SpriteViewImpl<'a>
impl<'a> SpriteViewImpl<'a>
Sourcepub const fn flip_horizontally(&self, flip_horizontally: bool) -> Self
pub const fn flip_horizontally(&self, flip_horizontally: bool) -> Self
Flip the sprite view horizontally
Sourcepub const fn flip_vertically(&self, flip_vertically: bool) -> Self
pub const fn flip_vertically(&self, flip_vertically: bool) -> Self
Flip the sprite view vertically
Trait Implementations§
Source§impl<'a> Clone for SpriteViewImpl<'a>
impl<'a> Clone for SpriteViewImpl<'a>
Source§fn clone(&self) -> SpriteViewImpl<'a>
fn clone(&self) -> SpriteViewImpl<'a>
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 moreimpl<'a> Copy for SpriteViewImpl<'a>
Source§impl<'a> From<&'a Sprite<'a>> for SpriteViewImpl<'a>
impl<'a> From<&'a Sprite<'a>> for SpriteViewImpl<'a>
Source§impl<'a> SpriteView<'a> for SpriteViewImpl<'a>
impl<'a> SpriteView<'a> for SpriteViewImpl<'a>
Source§fn rotate(&'a self, rotation: Rotation) -> SpriteViewImpl<'a>
fn rotate(&'a self, rotation: Rotation) -> SpriteViewImpl<'a>
Apply a rotation to the sprite view
Source§fn flip_horizontally(&'a self, flip_horizontally: bool) -> SpriteViewImpl<'a>
fn flip_horizontally(&'a self, flip_horizontally: bool) -> SpriteViewImpl<'a>
Flip the sprite view horizontally
Source§fn flip_vertically(&'a self, flip_vertically: bool) -> SpriteViewImpl<'a>
fn flip_vertically(&'a self, flip_vertically: bool) -> SpriteViewImpl<'a>
Flip the sprite view vertically
Auto Trait Implementations§
impl<'a> Freeze for SpriteViewImpl<'a>
impl<'a> RefUnwindSafe for SpriteViewImpl<'a>
impl<'a> Send for SpriteViewImpl<'a>
impl<'a> Sync for SpriteViewImpl<'a>
impl<'a> Unpin for SpriteViewImpl<'a>
impl<'a> UnsafeUnpin for SpriteViewImpl<'a>
impl<'a> UnwindSafe for SpriteViewImpl<'a>
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