Twease is a header only C++ library designed to provide utilities for animation, tweening, and easing functions. It facilitates smooth transitions between values and can be integrated into various applications requiring dynamic value changes over time.
To see easing functions as visually check Twease-Visualizer out!
- Tweening: Interpolate between sequences of values over a specified duration.
- Easing Functions: Provide various easing functions (e.g., linear, quadratic, cubic) for smooth animations.
- Animation: Transition smoothly between different states or values.
- Customizable: Easily integrate into existing C++ projects with customizable interpolation methods and easing functions.
#include <iostream>
#include <vector>
#include "Twease/Twease.h"
int main() {
double deltaTime = 0.016; // 60 FPS
auto anim = Twease::Animation<double>::animate(0.0, 100.0).during(2.0).easing(Twease::cubicIn);
while (!anim.isCompleted()) {
anim.update(deltaTime);
std::cout << "Current value: " << anim.getCurrentValue() << std::endl;
}
return 0;
}
#include <iostream>
#include <vector>
#include "Twease/Twease.h"
int main() {
auto helloworld = Twease::Tween<char>({ 'h', 'e', 'l', 'l', 'o' })
.to({ 'w', 'o', 'r', 'l', 'd' })
.during(50);
for (int i = 0; i <= helloworld.during(); ++i) {
std::vector<char> interpolatedSequence = helloworld.step(static_cast<double>(i) / helloworld.during());
for (char c : interpolatedSequence)
std::cout << c;
std::cout << std::endl;
}
return 0;
}