Return a copy using a new texture source rectangle.
Sprite
:= {
texture : Texture,
source : Rect,
pos : Vec2,
origin : Vec2,
rotation : F32,
scale : Vec2,
tint : Color,
}
Sprite module - pure helpers for texture sprites and simple animations.
Drawing still goes through Draw/Assets. This module provides a compact game-facing shape for sprites, spritesheet frame rectangles, and animation state.
Return a copy at a new destination position.
Return a copy with a new rotation and scaling origin.
centered : Sprite -> Sprite
Return a copy whose origin is centered in the scaled sprite.
Return a copy with rotation in degrees.
Return a copy with independent horizontal and vertical scale.
Return a copy with uniform scale.
Return a copy with a multiplicative tint.
to_texture_draw : Sprite -> TextureDraw
Resolve the sprite to a Draw.TextureDraw configuration.
Draw the sprite using its current transform and tint.
from_texture : Texture -> Sprite
Create a sprite covering the complete texture with identity transform.
with_source : Sprite, Rect -> Sprite
Compatibility function for the source receiver method.
Compatibility function for the pos receiver method.
with_origin : Sprite, Vec2 -> Sprite
Compatibility function for the origin receiver method.
with_origin_center : Sprite -> Sprite
Compatibility function for the centered receiver method.
with_rotation : Sprite, F32 -> Sprite
Compatibility function for the rotation receiver method.
with_scale_xy : Sprite, Vec2 -> Sprite
Compatibility function for the scale_xy receiver method.
with_scale : Sprite, F32 -> Sprite
Compatibility function for the scale receiver method.
Compatibility function for the tint receiver method.
sheet_frame : { frame_size : Vec2, row : U64, col : U64 } -> Rect
Return a source rectangle for a regular grid spritesheet.
Create animation state at its first frame.
Advance animation state by elapsed seconds without allocating.
animation_source : Animation, { frame_size : Vec2, row : U64 } -> Rect
Return the current frame's source rectangle for a spritesheet row.
Frame index and elapsed-time state for a regular spritesheet animation.