Skip to content

stdlib/spriteView source ↗

sprite

36 items · generated by scribe fromstdlib/sprite.fd· synced 2026-11-15

stdlib/sprite36 items

Contents

Animation

A single animation track (a sequence of frames with a frame duration).

pub struct Animation {

Fields:

NameType
frame_counti64
frame_durationf64
current_framei64
elapsedf64
playingbool
loopingbool
finishedbool

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: i64
  • frame_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 Animation
  • start_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 Animation
  • looping: 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 Animation
  • dt: 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:

NameType
xi64
yi64
widthi64
heighti64
origin_xi64
origin_yi64

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: i64
  • y: i64
  • width: i64
  • height: 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: i64
  • y: i64
  • width: i64
  • height: i64
  • origin_x: i64
  • origin_y: i64

Returns: AtlasRegion

Defined at line 133


Sprite

pub struct Sprite {

Fields:

NameType
src_rectAtlasRegion
pos_xf64
pos_yf64
scale_xf64
scale_yf64
rotationf64
visiblebool
flip_xbool
flip_ybool
alphaf64

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: AtlasRegion
  • x: f64
  • y: 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 Sprite
  • dx: f64
  • dy: 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 Sprite
  • x: f64
  • y: 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 Sprite
  • sx: f64
  • sy: 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 Sprite
  • rot: 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 Sprite
  • visible: 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 Sprite
  • alpha: 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 Sprite
  • flip: 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 Sprite
  • flip: 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 Sprite
  • src_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:

NameType
entriesVec<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 PaletteSwap
  • old_color: i64
  • new_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: PaletteSwap
  • color: 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: PaletteSwap
  • pixels: & mut Vec<i64>

Returns: void

Defined at line 268


AnimController

pub struct AnimController {

Fields:

NameType
animationsVec<Animation>
currenti64

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 AnimController
  • anim: 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 AnimController
  • track: 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 AnimController
  • dt: 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