static_interpolator

Macro static_interpolator 

Source
macro_rules! static_interpolator {
    ($(
        ($from:expr => $to:expr) [$($values_from:expr),+] => [$($values_to:expr),+]
    );+ $(;)?) => { ... };
}
Expand description

A macro to create a static linear interpolator.
This macro is a convenience wrapper around LinearInterpolator::new_from_raw.

The syntax is a series of semicolon separated statements of the form:
(start => end) [values_from] => [values_to];

Where:

  • start..=end form an inclusive range
  • values_from and values_to are arrays of values to interpolate between

ยงExample

use lineic::{static_interpolator, LinearInterpolator};

const MY_INTERPOLATOR: LinearInterpolator<3, f32, f32> = static_interpolator! {
    (0.0 => 50.0) [0.0, 0.0, 0.0] => [1.0, 1.0, 1.0];
    (50.0 => 100.0) [1.0, 1.0, 1.0] => [2.0, 2.0, 2.0];
};