Sunday, July 31, 2016

Tweeny, A Modern C++ Tweening Library

Tweeny, A Modern C++ Tweening Library

Hello! This post is to announce Tweeny, an inbetweening library for C++. It provides a fluid API for defining tweens, like:

auto tween = tweeny::from(0).to(50).during(100);
while (tween.progress() < 1) tween.step(1);

It supports tweens with multiple points (e.g, from 0 to 100 then to 200), multiple values (from 0, 0 to 100, 200) and multiple types (from 0, 0.0f to 10, 2.5f). It also has 30+ easing functions (based on those by Robert Penner http://ift.tt/1mCMeMf).

 

Here is a demo, compiled with emscripten, of a sprite using tweens: http://ift.tt/2aJELOV

 

- Source: http://ift.tt/2aHCbMg

- Site: http://ift.tt/2aJDZ4r

- API Doc and Manual: http://ift.tt/2aHBl2o

 

For those wondering what a tween is or why is it useful, every Game UI nowadays has some sort of tween in them: panels fade in/out, buttons wobble when hovered, things slide in/out with acceleration/deacceleration, etc. All of those pretty animations are possible through a tween with a specific easing.

 

The purpose of Tweeny is to facilitate that. For instance, to animate a button size, this is a possible solution:

auto tween = tweeny::from(button.w, button.h).to(button.w + 10, button.h + 10).during(200).via(easing::backOut);
tween.onStep([](int w, int h) { button.w = w; button.h = h; return false; });

/* later, in game loop */
tween.step(dt);

Tweeny is MIT licensed.

 

I hope this can be useful to you. Feedback is much appreciated!


No comments:

Post a Comment