deetween 0.0.2

A cool animation library for the D programming language.


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

📽 Deetween

A cool animation library for the D programming language. Deetween is a single-file library designed to be a simple foundation for creating complex animation systems.

Types

  • EasingFunc
  • TweenMode
  • Tween
  • FrameTween
  • Keyframe
  • KeyframeGroup

Examples

Tween

A simple a-to-b animation that lasts 1.0 seconds.

import deetween;

void main() {
    enum a = 9.0;
    enum b = 20.0;
    enum totalDuration = 1.0;
    enum dt = 0.001;

    auto tween = Tween(a, b, totalDuration, TweenMode.bomb);

    assert(tween.now == a);
    while (!tween.hasFinished) {
        float value = tween.update(dt);
        assert(value >= a && value <= b);
    }
    assert(tween.now == b);
}

FrameTween

A simple a-to-b animation where each value lasts 0.1 seconds.

import deetween;

void main() {
    enum a = 9;
    enum b = 20;
    enum frameDuration = 0.1;
    enum dt = 0.001;

    auto tween = FrameTween(a, b, frameDuration, TweenMode.bomb);

    assert(tween.now == a);
    while (!tween.hasFinished) {
        int value = tween.update(dt);
        assert(value >= a && value <= b);
    }
    assert(tween.now == b);
}

KeyframeGroup

A simple a-to-b animation lasting 1.0 seconds.

import deetween;

void main() {
    enum a = 9.0;
    enum b = 20.0;
    enum totalDuration = 1.0;
    enum dt = 0.001;

    auto group = KeyframeGroup(totalDuration, TweenMode.bomb);
    group.append(Keyframe(a, 0.0));
    group.append(Keyframe(b, totalDuration));

    assert(group.length == 2);
    assert(group.now == a);
    while (!group.hasFinished) {
        float value = group.update(dt);
        assert(value >= a && value <= b);
    }
    assert(group.now == b);
    group.clear();
    assert(group.length == 0);
}

Influences

Credits

The easing functions were ported from JavaScript to D from this site.

License

The project is released under the terms of the Apache-2.0 License. Please refer to the LICENSE file.

Authors:
  • Alexandros F. G. Kapretsos
Dependencies:
none
Versions:
0.0.6 2023-Sep-11
0.0.5 2023-Aug-23
0.0.4 2023-Aug-11
0.0.3 2023-Aug-06
0.0.2 2023-Aug-03
Show all 7 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 61 downloads total

Score:
0.4
Short URL:
deetween.dub.pm