Skip to content

[Feature] Tweening/property animation #157

@vmarcella

Description

@vmarcella

Overview

Add a tweening system for animating numeric properties over time with various
easing functions.

Current State

No response

Scope

Goals:

  • Tween any numeric value from start to end
  • Support common easing functions (linear, ease-in/out, etc.)
  • Duration-based animation
  • Completion callbacks

Non-Goals:

  • Skeletal animation
  • Keyframe animation
  • Physics-based animation

Proposed API

// crates/lambda-rs/src/animation/tween.rs
pub enum Easing {
  Linear,
  EaseInQuad,
  EaseOutQuad,
  EaseInOutQuad,
  EaseInCubic,
  EaseOutCubic,
  EaseInOutCubic,
  // ... more
}

pub struct Tween<T> {
  start: T,
  end: T,
  duration: f32,
  elapsed: f32,
  easing: Easing,
}

impl<T: Lerp> Tween<T> {
  pub fn new(start: T, end: T, duration: f32) -> Self;
  pub fn with_easing(self, easing: Easing) -> Self;
  pub fn update(&mut self, dt: f32) -> bool; // returns true when complete
  pub fn value(&self) -> T;
  pub fn progress(&self) -> f32; // 0.0 to 1.0
  pub fn reset(&mut self);
}

pub trait Lerp {
  fn lerp(a: &Self, b: &Self, t: f32) -> Self;
}

Acceptance Criteria

  • Linear interpolation works correctly
  • Easing functions produce expected curves
  • Tween completes at exact duration
  • Progress clamped to 0.0-1.0
  • Works with f32, [f32; 2], [f32; 3], [f32; 4]

Affected Crates

lambda-rs

Notes

  • Use Robert Penner easing functions as a reference
  • Consider sequence/chain API

Metadata

Metadata

Assignees

No one assigned

    Labels

    animationAll things related to animationsenhancementNew feature or requestlambda-rsIssues pertaining to the core framework

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions