Skip to main content

Module interpolate

Module interpolate 

Source
Expand description

Interpolation math for SpriteStudio animation curves.

Curve evaluation with no dependency on ssab or any other SpriteStudio type — just numbers in, numbers out. Linear, Hermite and Bezier interpolation plus the easing rate functions, generic over SsFloat so the same code serves f32 and f64; the interpolate_*_linear batch helpers are f32 only.

use ssruntime::interpolate::{linear, rate_ease_in};

assert_eq!(linear(0.0f32, 100.0, 0.5), 50.0);
assert_eq!(linear(0.0f64, 100.0, 0.5), 50.0); // same code path, f64

// Easing shapes the rate, which then drives the interpolation.
let eased = linear(0.0f32, 100.0, rate_ease_in(0.5, 2.0));
assert!(eased < 50.0);

Traits§

SsFloat
A trait to abstract floating-point operations for generic interpolation.

Functions§

bezier
hermite
interpolate_array_linear
Batch linear interpolation for arrays (e.g. Deform attributes).
interpolate_color_linear
Batch linear interpolation for PartColor attribute (fixed 16 floats: four channels each for LT, RT, LB, RB).
interpolate_vertex_linear
Batch linear interpolation for Vertex attribute (fixed 8 floats: LT.x, LT.y, RT.x, RT.y, LB.x, LB.y, RB.x, RB.y).
linear
rate_accelerate
rate_decelerate
rate_ease_back_in
rate_ease_back_inout
rate_ease_back_out
rate_ease_bounce_in
rate_ease_bounce_inout
rate_ease_bounce_out
rate_ease_elastic_in
rate_ease_elastic_inout
rate_ease_elastic_out
rate_ease_exponential_in
rate_ease_exponential_inout
rate_ease_exponential_out
rate_ease_in
rate_ease_inout
rate_ease_out
rate_ease_sine_in
rate_ease_sine_inout
rate_ease_sine_out
rate_linear