use std::future::Future;
use std::time::Duration;
use crate::linalg::Transform3D;
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Keyframe<T> {
pub time: Duration,
pub value: T,
}
#[derive(Clone, Debug, PartialEq)]
pub struct KeyframeAnimation<T> {
pub duration: Duration,
pub keyframes: Vec<Keyframe<T>>,
}
#[derive(Clone, Debug, PartialEq)]
pub enum Animation {
Opacity(KeyframeAnimation<f32>),
Transform(KeyframeAnimation<Transform3D<f32>>),
}
pub trait AnimationHandle: Future<Output = ()> + Send + Sync {}
pub trait Animator {
type AnimationHandle: AnimationHandle;
fn start(&mut self, animation: Animation) -> Self::AnimationHandle;
}
pub trait Animatable {
type Animator: Animator;
type CommandBuffer;
fn animate<F>(&mut self, animations: F)
where
F: FnOnce(&mut Self::Animator) + Send + 'static;
fn animate_with_buffer<F>(&mut self, buffer: &mut Self::CommandBuffer, animations: F)
where
F: FnOnce(&mut Self::Animator) + Send + 'static;
}