tweener 0.1.1

One-dimensional tweening library.
Documentation
  • Coverage
  • 29.31%
    34 out of 116 items documented1 out of 15 items with examples
  • Size
  • Source code size: 119.0 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 334.4 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • setanarut

Docs

tweener is a one-dimensional tweening library.

Features

  • 41 easing functions
  • Optional serde feature enables serialization and deserialization of the Tween struct (useful for games). Enable it in Cargo.toml with features = ["serde"].
  • Yoyo animation feature
  • Animation durations use the std::time::Duration type (easy-to-read code).
  • The f32 submodule can be used for the f32 Tween type. use tweener::f32::*;

Quick start

use std::time::Duration;
use tweener::{Easing, Tween};

fn main() {

    // Tween from 0 to 1 in 3 seconds.
    let mut tw = Tween::new(0.0, 1.0, Duration::from_secs(3), Easing::Linear, false);

    // Advance by 1.5 seconds.
    tw.update(Duration::from_millis(1500));

    // Get tween value at 1.5 seconds.
    println!("{}", tw.value); // 0.5

    // Is the animation finished?
    println!("{}", tw.is_finished()); // false
}

Easing functions

family in out inOut outIn
Linear Linear Linear Linear Linear
Quad InQuad OutQuad InOutQuad OutInQuad
Cubic InCubic OutCubic InOutCubic OutInCubic
Quart InQuart OutQuart InOutQuart OutInQuart
Quint InQuint OutQuint InOutQuint OutInQuint
Expo InExpo OutExpo InOutExpo OutInExpo
Sine InSine OutSine InOutSine OutInSine
Circ InCirc OutCirc InOutCirc OutInCirc
Back InBack OutBack InOutBack OutInBack
Bounce InBounce OutBounce InOutBounce OutInBounce
Elastic InElastic OutElastic InOutElastic OutInElastic

See easings.net for online visualization.