stdlib/spriteView source ↗
sprite
36 items · generated by scribe fromstdlib/sprite.fd· synced 2026-11-15
Contents
- Animation (struct)
- sprite_anim_create (function)
- sprite_anim_play (function)
- sprite_anim_stop (function)
- sprite_anim_set_looping (function)
- sprite_anim_update (function)
- sprite_anim_reset (function)
- sprite_anim_is_finished (function)
- sprite_anim_get_frame (function)
- sprite_anim_total_duration (function)
- AtlasRegion (struct)
- sprite_region_new (function)
- sprite_region_with_origin (function)
- Sprite (struct)
- sprite_create (function)
- sprite_move (function)
- sprite_set_pos (function)
- sprite_set_scale (function)
- sprite_set_rotation (function)
- sprite_set_visible (function)
- sprite_set_alpha (function)
- sprite_set_flip_x (function)
- sprite_set_flip_y (function)
- sprite_set_region (function)
- sprite_bounds (function)
- PaletteSwap (struct)
- sprite_palette_create (function)
- sprite_palette_add (function)
- sprite_palette_apply (function)
- sprite_palette_apply_buffer (function)
- AnimController (struct)
- sprite_controller_create (function)
- sprite_controller_add (function)
- sprite_controller_play (function)
- sprite_controller_update (function)
- sprite_controller_current_track (function)
Animation
A single animation track (a sequence of frames with a frame duration).
pub struct Animation {Fields:
| Name | Type |
|---|---|
frame_count | i64 |
frame_duration | f64 |
current_frame | i64 |
elapsed | f64 |
playing | bool |
looping | bool |
finished | bool |
Defined at line 16
sprite_anim_create
Create a new animation with the given frame count and duration per frame.
pub fn sprite_anim_create(frame_count: i64, frame_duration: f64) -> Animation {Parameters:
frame_count:i64frame_duration:f64
Returns: Animation
Defined at line 33
sprite_anim_play
Start playing the animation from a specific frame.
pub fn sprite_anim_play(anim: & mut Animation, start_frame: i64) -> void {Parameters:
anim:& mut Animationstart_frame:i64
Returns: void
Defined at line 40
sprite_anim_stop
Stop the animation.
pub fn sprite_anim_stop(anim: & mut Animation) -> void {Parameters:
anim:& mut Animation
Returns: void
Defined at line 48
sprite_anim_set_looping
Set whether the animation loops.
pub fn sprite_anim_set_looping(anim: & mut Animation, looping: bool) -> void {Parameters:
anim:& mut Animationlooping:bool
Returns: void
Defined at line 53
sprite_anim_update
Advance the animation by dt seconds. Returns the current frame index.
pub fn sprite_anim_update(anim: & mut Animation, dt: f64) -> i64 {Parameters:
anim:& mut Animationdt:f64
Returns: i64
Defined at line 58
sprite_anim_reset
Reset the animation to frame 0.
pub fn sprite_anim_reset(anim: & mut Animation) -> void {Parameters:
anim:& mut Animation
Returns: void
Defined at line 85
sprite_anim_is_finished
Check if a non-looping animation has finished.
pub fn sprite_anim_is_finished(anim: Animation) -> bool {Parameters:
anim:Animation
Returns: bool
Defined at line 92
sprite_anim_get_frame
Get the current frame without advancing.
pub fn sprite_anim_get_frame(anim: Animation) -> i64 {Parameters:
anim:Animation
Returns: i64
Defined at line 97
sprite_anim_total_duration
Get the total duration of the animation in seconds.
pub fn sprite_anim_total_duration(anim: Animation) -> f64 {Parameters:
anim:Animation
Returns: f64
Defined at line 102
AtlasRegion
pub struct AtlasRegion {Fields:
| Name | Type |
|---|---|
x | i64 |
y | i64 |
width | i64 |
height | i64 |
origin_x | i64 |
origin_y | i64 |
Defined at line 111
sprite_region_new
Create a default atlas region (top-left origin).
pub fn sprite_region_new(x: i64, y: i64, width: i64, height: i64) -> AtlasRegion {Parameters:
x:i64y:i64width:i64height:i64
Returns: AtlasRegion
Defined at line 126
sprite_region_with_origin
Create an atlas region with a custom origin point.
pub fn sprite_region_with_origin(x: i64, y: i64, width: i64, height: i64, origin_x: i64, origin_y: i64) -> AtlasRegion {Parameters:
x:i64y:i64width:i64height:i64origin_x:i64origin_y:i64
Returns: AtlasRegion
Defined at line 133
Sprite
pub struct Sprite {Fields:
| Name | Type |
|---|---|
src_rect | AtlasRegion |
pos_x | f64 |
pos_y | f64 |
scale_x | f64 |
scale_y | f64 |
rotation | f64 |
visible | bool |
flip_x | bool |
flip_y | bool |
alpha | f64 |
Defined at line 141
sprite_create
Create a sprite from an atlas region at a world position.
pub fn sprite_create(src_rect: AtlasRegion, x: f64, y: f64) -> Sprite {Parameters:
src_rect:AtlasRegionx:f64y:f64
Returns: Sprite
Defined at line 164
sprite_move
Move a sprite by (dx, dy).
pub fn sprite_move(s: & mut Sprite, dx: f64, dy: f64) -> void {Parameters:
s:& mut Spritedx:f64dy:f64
Returns: void
Defined at line 171
sprite_set_pos
Set the sprite’s position.
pub fn sprite_set_pos(s: & mut Sprite, x: f64, y: f64) -> void {Parameters:
s:& mut Spritex:f64y:f64
Returns: void
Defined at line 177
sprite_set_scale
Set the sprite’s scale.
pub fn sprite_set_scale(s: & mut Sprite, sx: f64, sy: f64) -> void {Parameters:
s:& mut Spritesx:f64sy:f64
Returns: void
Defined at line 183
sprite_set_rotation
Set the sprite’s rotation (radians).
pub fn sprite_set_rotation(s: & mut Sprite, rot: f64) -> void {Parameters:
s:& mut Spriterot:f64
Returns: void
Defined at line 189
sprite_set_visible
Set the sprite’s visibility.
pub fn sprite_set_visible(s: & mut Sprite, visible: bool) -> void {Parameters:
s:& mut Spritevisible:bool
Returns: void
Defined at line 194
sprite_set_alpha
Set the sprite’s alpha (opacity).
pub fn sprite_set_alpha(s: & mut Sprite, alpha: f64) -> void {Parameters:
s:& mut Spritealpha:f64
Returns: void
Defined at line 199
sprite_set_flip_x
Flip the sprite horizontally.
pub fn sprite_set_flip_x(s: & mut Sprite, flip: bool) -> void {Parameters:
s:& mut Spriteflip:bool
Returns: void
Defined at line 204
sprite_set_flip_y
Flip the sprite vertically.
pub fn sprite_set_flip_y(s: & mut Sprite, flip: bool) -> void {Parameters:
s:& mut Spriteflip:bool
Returns: void
Defined at line 209
sprite_set_region
Change the atlas region (e.g., for animation frame swapping).
pub fn sprite_set_region(s: & mut Sprite, src_rect: AtlasRegion) -> void {Parameters:
s:& mut Spritesrc_rect:AtlasRegion
Returns: void
Defined at line 214
sprite_bounds
Get the sprite’s bounding box (for collision).
pub fn sprite_bounds(s: Sprite) -> (f64, f64, f64, f64) {Parameters:
s:Sprite
Returns: (f64, f64, f64, f64)
Defined at line 219
PaletteSwap
pub struct PaletteSwap {Fields:
| Name | Type |
|---|---|
entries | Vec<i64> |
Defined at line 237
sprite_palette_create
Create an empty palette swap.
pub fn sprite_palette_create() -> PaletteSwap {Returns: PaletteSwap
Defined at line 242
sprite_palette_add
Add a color mapping: old_color → new_color.
pub fn sprite_palette_add(palette: & mut PaletteSwap, old_color: i64, new_color: i64) -> void {Parameters:
palette:& mut PaletteSwapold_color:i64new_color:i64
Returns: void
Defined at line 249
sprite_palette_apply
Apply the palette swap to a single pixel color. Returns the new color if found, otherwise the original.
pub fn sprite_palette_apply(palette: PaletteSwap, color: i64) -> i64 {Parameters:
palette:PaletteSwapcolor:i64
Returns: i64
Defined at line 256
sprite_palette_apply_buffer
Apply the palette swap to a buffer of pixels (in-place).
pub fn sprite_palette_apply_buffer(palette: PaletteSwap, pixels: & mut Vec<i64>) -> void {Parameters:
palette:PaletteSwappixels:& mut Vec<i64>
Returns: void
Defined at line 268
AnimController
pub struct AnimController {Fields:
| Name | Type |
|---|---|
animations | Vec<Animation> |
current | i64 |
Defined at line 283
sprite_controller_create
Create an empty animation controller.
pub fn sprite_controller_create() -> AnimController {Returns: AnimController
Defined at line 289
sprite_controller_add
Add an animation track to the controller. Returns the track index.
pub fn sprite_controller_add(controller: & mut AnimController, anim: Animation) -> i64 {Parameters:
controller:& mut AnimControlleranim:Animation
Returns: i64
Defined at line 296
sprite_controller_play
Switch to a specific animation track by index.
pub fn sprite_controller_play(controller: & mut AnimController, track: i64) -> void {Parameters:
controller:& mut AnimControllertrack:i64
Returns: void
Defined at line 303
sprite_controller_update
Update the current animation. Returns the current frame.
pub fn sprite_controller_update(controller: & mut AnimController, dt: f64) -> i64 {Parameters:
controller:& mut AnimControllerdt:f64
Returns: i64
Defined at line 314
sprite_controller_current_track
Get the current animation track index.
pub fn sprite_controller_current_track(controller: AnimController) -> i64 {Parameters:
controller:AnimController
Returns: i64
Defined at line 327
Generated by scribe, the Fides documentation generator