deetween 0.0.6

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
  • Keyframe
  • KeyframeGroup
  • ValueSequence

Examples

Tween

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

import deetween;

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

    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);
}

KeyframeGroup

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

import deetween;

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

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

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

ValueSequence

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

import deetween;

void main() {
    const a = 9;
    const b = 20;
    const valueDuration = 0.1f;
    const dt = 0.001f;

    auto sequence = ValueSequence(a, b, valueDuration, TweenMode.bomb);

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

Influences

Credits

  • The easing functions were ported from JavaScript to D from this site.
  • Some functions were written using this site as a reference.

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

  • 2 downloads this month

  • 63 downloads total

Score:
0.4
Short URL:
deetween.dub.pm