pub struct WalkSprite {
pub frame_w: u32,
pub frame_h: u32,
pub rows: u32,
pub cols: u32,
/* private fields */
}Expand description
A walk-cycle sprite sheet sliced into uniform frame_w × frame_h cells.
Fields§
§frame_w: u32§frame_h: u32§rows: u32§cols: u32Implementations§
Source§impl WalkSprite
impl WalkSprite
Sourcepub fn from_rgba(
pixels: Vec<Rgba>,
sheet_w: u32,
sheet_h: u32,
frame_w: u32,
frame_h: u32,
) -> Result<Self, String>
pub fn from_rgba( pixels: Vec<Rgba>, sheet_w: u32, sheet_h: u32, frame_w: u32, frame_h: u32, ) -> Result<Self, String>
Build from decoded RGBA pixels (sheet_w * sheet_h), sliced into cells.
Sourcepub fn pixel(&self, row: u32, col: u32, fx: u32, fy: u32) -> Rgba
pub fn pixel(&self, row: u32, col: u32, fx: u32, fy: u32) -> Rgba
Pixel of frame (row, col) at frame-local (fx, fy); transparent if out of range.
Sourcepub fn draw_on_tile(
&self,
fb: &mut FrameBuffer,
row: u32,
col: u32,
foot_x: i32,
foot_y: i32,
tile: i32,
)
pub fn draw_on_tile( &self, fb: &mut FrameBuffer, row: u32, col: u32, foot_x: i32, foot_y: i32, tile: i32, )
Blit frame (row, col) bottom-centred on the foot tile whose top-left is
(foot_x, foot_y) in screen pixels (tile size tile); the head extends above.
Transparent pixels are skipped; drawing is clipped to the framebuffer.
Auto Trait Implementations§
impl Freeze for WalkSprite
impl RefUnwindSafe for WalkSprite
impl Send for WalkSprite
impl Sync for WalkSprite
impl Unpin for WalkSprite
impl UnsafeUnpin for WalkSprite
impl UnwindSafe for WalkSprite
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.