Gama C Library
Gama C API Documentation
animate.h File Reference

Provides utility functions for animating numerical values using various easing effects. More...

#include "_math.h"
#include "gapi.h"
#include <stdlib.h>

Go to the source code of this file.

Functions

void gm_anim_spring (double *value, double target, double t)
 Animates a value towards a target with a smooth, ease-out effect.
void gm_anim_ease_out_quad (double *value, const double target, double t)
 Animates a value towards a target with a quadratic ease-out effect.
void gm_anim_ease_out_cubic (double *value, double target, double t)
 Animates a value towards a target with a cubic ease-out effect.
void gm_anim_ease_in_quad (double *value, double target, double t)
 Animates a value towards a target with a quadratic ease-in effect.

Detailed Description

Provides utility functions for animating numerical values using various easing effects.

This file contains a collection of inline functions designed to smoothly transition a double value towards a target value over time, using different animation curves (easing functions). These are commonly used for UI transitions, movement, and other visual effects.

General notes on animation functions:

  • value: A pointer to the variable to be animated. This variable is modified directly.
  • target: The target value that value will animate towards.
  • t: The approximate time constant for the animation (in seconds). A smaller t generally results in a faster or more "springy" animation.

Function Documentation

◆ gm_anim_ease_in_quad()

void gm_anim_ease_in_quad ( double * value,
double target,
double t )

Animates a value towards a target with a quadratic ease-in effect.

The animation starts slow and accelerates quadratically as it approaches the target.

Parameters
valueA pointer to the double value to animate.
targetThe target value to animate towards.
tThe animation's approximate duration (time constant).

◆ gm_anim_ease_out_cubic()

void gm_anim_ease_out_cubic ( double * value,
double target,
double t )

Animates a value towards a target with a cubic ease-out effect.

The animation starts very fast and decelerates cubically as it approaches the target, providing a more pronounced ease-out than gm_anim_ease_out_quad.

Parameters
valueA pointer to the double value to animate.
targetThe target value to animate towards.
tThe animation's approximate duration (time constant).

◆ gm_anim_ease_out_quad()

void gm_anim_ease_out_quad ( double * value,
const double target,
double t )

Animates a value towards a target with a quadratic ease-out effect.

The animation starts fast and decelerates quadratically as it approaches the target.

Parameters
valueA pointer to the double value to animate.
targetThe target value to animate towards.
tThe animation's approximate duration (time constant).

◆ gm_anim_spring()

void gm_anim_spring ( double * value,
double target,
double t )

Animates a value towards a target with a smooth, ease-out effect.

This function creates a spring-like motion that quickly moves towards the target and then gradually settles. The t parameter controls the speed and "stiffness" of the spring.

Parameters
valueA pointer to the double value to animate. This value is updated in place.
targetThe target value to animate towards.
tThe animation's approximate duration (time constant). A smaller 't' results in a faster, more immediate animation.