use crate::animatable::Animatable;
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum PropertyValue {
Scalar(f32),
Vector2(iced::Vector),
Size(iced::Size),
Rectangle(iced::Rectangle),
Transform(TransformValue),
Color(iced::Color),
Shadow(iced::Shadow),
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct TransformValue {
pub translate_x: f32,
pub translate_y: f32,
pub scale: f32,
pub rotate: f32,
}
impl TransformValue {
#[must_use]
pub const fn new(translate_x: f32, translate_y: f32, scale: f32, rotate: f32) -> Self {
Self {
translate_x,
translate_y,
scale,
rotate,
}
}
#[must_use]
pub const fn identity() -> Self {
Self::new(0.0, 0.0, 1.0, 0.0)
}
}
impl Animatable for TransformValue {
fn interpolate_progress(
from: Self,
to: Self,
progress: crate::animatable::InterpolationProgress,
) -> Self {
TransformValue::new(
f32::interpolate_progress(from.translate_x, to.translate_x, progress),
f32::interpolate_progress(from.translate_y, to.translate_y, progress),
f32::interpolate_progress(from.scale, to.scale, progress),
f32::interpolate_progress(from.rotate, to.rotate, progress),
)
}
}