Skip to content

stdlib/animation2dView source ↗

animation2d

19 items · generated by scribe fromstdlib/animation2d.fd· synced 2026-11-15

stdlib/animation2d19 items

Contents

AnimState2D

pub struct AnimState2D {

Fields:

NameType
namestr
start_framei64
frame_counti64
frame_timef64
loopingbool
rowi64

Defined at line 21


Animation2D

pub struct Animation2D {

Fields:

NameType
statesVec<AnimState2D>
current_statei64
current_framei64
elapsedf64
finishedbool
speedf64
frame_wi64
frame_hi64

Defined at line 33


anim2d_create

Create an animation system with the given frame dimensions.

pub fn anim2d_create(frame_w: i64, frame_h: i64) -> Animation2D {

Parameters:

  • frame_w: i64
  • frame_h: i64

Returns: Animation2D

Defined at line 51


anim2d_add_state

Add an animation state. Returns the state index.

pub fn anim2d_add_state(anim: & mut Animation2D, name: str, start_frame: i64, frame_count: i64, frame_time: f64, looping: bool) -> i64 {

Parameters:

  • anim: & mut Animation2D
  • name: str
  • start_frame: i64
  • frame_count: i64
  • frame_time: f64
  • looping: bool

Returns: i64

Defined at line 59


anim2d_add_state_row

Add an animation state with a specific row in the sprite sheet.

pub fn anim2d_add_state_row(anim: & mut Animation2D, name: str, start_frame: i64, frame_count: i64, frame_time: f64, looping: bool, row: i64) -> i64 {

Parameters:

  • anim: & mut Animation2D
  • name: str
  • start_frame: i64
  • frame_count: i64
  • frame_time: f64
  • looping: bool
  • row: i64

Returns: i64

Defined at line 68


anim2d_find_state

Find a state by name. Returns index or -1.

pub fn anim2d_find_state(anim: & Animation2D, name: str) -> i64 {

Parameters:

  • anim: & Animation2D
  • name: str

Returns: i64

Defined at line 77


anim2d_play

Play an animation state by name. Returns true if found.

pub fn anim2d_play(anim: & mut Animation2D, name: str) -> bool {

Parameters:

  • anim: & mut Animation2D
  • name: str

Returns: bool

Defined at line 89


anim2d_play_idx

Play an animation state by index.

pub fn anim2d_play_idx(anim: & mut Animation2D, idx: i64) -> void {

Parameters:

  • anim: & mut Animation2D
  • idx: i64

Returns: void

Defined at line 106


anim2d_update

Update the animation.

pub fn anim2d_update(anim: & mut Animation2D, dt: f64) -> void {

Parameters:

  • anim: & mut Animation2D
  • dt: f64

Returns: void

Defined at line 120


anim2d_current_frame

Get the current frame index (absolute, in the sprite sheet).

pub fn anim2d_current_frame(anim: & Animation2D) -> i64 {

Parameters:

  • anim: & Animation2D

Returns: i64

Defined at line 144


anim2d_current_row

Get the current row in the sprite sheet.

pub fn anim2d_current_row(anim: & Animation2D) -> i64 {

Parameters:

  • anim: & Animation2D

Returns: i64

Defined at line 153


anim2d_source_rect

Get the source rectangle (x, y, w, h) in the sprite sheet.

pub fn anim2d_source_rect(anim: & Animation2D, sheet_cols: i64) -> vec4 {

Parameters:

  • anim: & Animation2D
  • sheet_cols: i64

Returns: vec4

Defined at line 161


anim2d_current_state_name

Get the name of the current state.

pub fn anim2d_current_state_name(anim: & Animation2D) -> str {

Parameters:

  • anim: & Animation2D

Returns: str

Defined at line 170


anim2d_is_finished

Check if the current animation has finished.

pub fn anim2d_is_finished(anim: & Animation2D) -> bool {

Parameters:

  • anim: & Animation2D

Returns: bool

Defined at line 178


anim2d_set_speed

Set playback speed.

pub fn anim2d_set_speed(anim: & mut Animation2D, speed: f64) -> void {

Parameters:

  • anim: & mut Animation2D
  • speed: f64

Returns: void

Defined at line 183


anim2d_reset

Reset the current animation to frame 0.

pub fn anim2d_reset(anim: & mut Animation2D) -> void {

Parameters:

  • anim: & mut Animation2D

Returns: void

Defined at line 191


anim2d_state_count

Get the number of states.

pub fn anim2d_state_count(anim: & Animation2D) -> i64 {

Parameters:

  • anim: & Animation2D

Returns: i64

Defined at line 198


anim2d_duration

Get the total duration of the current animation in seconds.

pub fn anim2d_duration(anim: & Animation2D) -> f64 {

Parameters:

  • anim: & Animation2D

Returns: f64

Defined at line 203


anim2d_progress

Get the progress (0..1) of the current animation.

pub fn anim2d_progress(anim: & Animation2D) -> f64 {

Parameters:

  • anim: & Animation2D

Returns: f64

Defined at line 212


Generated by scribe, the Fides documentation generator