diff options
-rw-r--r-- | src/interpolation.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/interpolation.rs b/src/interpolation.rs index 17e4a48..4543ffb 100644 --- a/src/interpolation.rs +++ b/src/interpolation.rs @@ -21,9 +21,14 @@ where } #[derive(Clone, Copy)] -pub enum TimingFunction { +pub enum TwoValueTimingFunction { Lerp, } +#[derive(Clone, Copy)] +pub enum ManyValueTimingFunction { + Bezier, +} + #[derive(Clone, Copy, PartialEq, PartialOrd)] // We could make a TimeType generic (I initially did), however it's safe to assume we use a 64-bit float for this pub struct KeyFrame<ValueType> { @@ -50,7 +55,7 @@ impl< from: &KeyFrame<ValueType>, to: &KeyFrame<ValueType>, time: f64, - timing_function: TimingFunction, + timing_function: TwoValueTimingFunction, ) -> ValueType { // Order them so `from` is always the lower bound let (from, to) = if from.time < to.time { @@ -61,7 +66,7 @@ impl< let length = to.time - from.time; let position = (time - from.time) / length; match timing_function { - TimingFunction::Lerp => raw_lerp(from.val, to.val, position), + TwoValueTimingFunction::Lerp => raw_lerp(from.val, to.val, position), } } } @@ -161,7 +166,7 @@ impl< // We have the user pass this, as to prevent needing to constantly re-calculate it. sorted_keyframes: Vec<KeyFrame<ValueType>>, time: f64, - timing_function: TimingFunction, + timing_function: TwoValueTimingFunction, ) -> Option<ValueType> { let frames = self.get_current_keyframes(sorted_keyframes, time); match frames { |