deetween 0.0.1
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 provide a simple foundation for creating complex animation systems.
Types
- EasingFunc
- TweenMode
- Tween
- Keyframe
- KeyframeGroup
Examples
Tween
A simple from-a-to-b animation lasting 1.0 seconds.
import deetween;
void main() {
enum a = 69;
enum b = 420;
enum dt = 0.01;
enum duration = 1.0;
auto tween = Tween(a, b, duration, &easeLinear, 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 from-a-to-b animation lasting 1.0 seconds.
import deetween;
void main() {
enum a = 69;
enum b = 420;
enum dt = 0.01;
enum duration = 1.0;
auto group = KeyframeGroup(duration, &easeLinear, TweenMode.bomb);
group.append(Keyframe(a, 0.0));
group.append(Keyframe(b, duration));
assert(group.now == a);
while (!group.hasFinished) {
float value = group.update(dt);
assert(value >= a && value <= b);
}
assert(group.now == b);
}
A walking animation with 3 frames lasting 0.3 seconds.
import deetween;
void main() {
enum duration = 0.3;
auto walkAnim = KeyframeGroup(duration, &easeNearest, TweenMode.loop);
walkAnim.appendEvenly(0, 1, 2, 2);
float dt = duration / (walkAnim.keys.length - 1) + 0.001;
assert(walkAnim.now == walkAnim.keys[0].value);
foreach (i; 1 .. walkAnim.keys.length - 1) {
assert(walkAnim.update(dt) == walkAnim.keys[i].value);
}
}
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.
- Registered by Alexandros F. G. Kapretsos
- 0.0.1 released a year ago
- AlexandrosKap/deetween
- Apache-2.0
- Copyright © 2023, Alexandros F. G. Kapretsos
- Authors:
- 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 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
64 downloads total
-
- Score:
- 0.4
- Short URL:
- deetween.dub.pm