vsrg 0.3.0

Data structures for vertical scrolling rhythm games
Documentation
//! Provides easing variants as enums, and mathematic operations on them.
//!
//! This module provides two easing enums: [`Easing`] and [`AdvancedEasing`], with the distinction
//! that [`Easing`] only contains "simple" easings that are monotonic over time, and
//! [`AdvancedEasing`] contains all supported easings.
//!
//! It supports the following calculations:
//! - Eased value from easing parameter
//! - Derivative
//! - Integration over easing parameter
//! - Integration of reciprocal of eased value
//! - Solving for easing parameter from eased value
//! - Solving for easing parameter from integration result
//! - Solving for easing parameter from result of integrating reciprocal
//!
//! Note that some calculations are not available for [`AdvancedEasing`], namely: solving
//! integration and solving integration of reciprocal. Integration of [`AdvancedEasing`] is also
//! gated behind `lut_integration` feature flag, since they requires bundling LUT in static memory that
//! may bloat your build size.

mod conversion;
mod derivative;
mod eval;
mod integration;
mod integration_reciprocal;
mod solve;
mod solve_integration;
mod solve_integration_reciprocal;
mod types;

#[cfg(test)]
mod test_finiteness;

pub use types::{AdvancedEasing, Easable, Easing};

#[inline]
fn split_and_calc<T, const N: usize>(from: T, to: T, t: T, f: impl Fn(f64, f64, f64) -> f64) -> T
where
    T: Easable<N>,
{
    let from = from.components();
    let to = to.components();
    let t = t.components();

    T::compose(std::array::from_fn(|i| f(from[i], to[i], t[i])))
}