ofxTweener proposal

Hello all,

I’m currently starting my first project with OF. I’ve been working with actionscript a lot and miss a convenient tweening tool in OF. I’ve seen there has been an attempt to create a tweener, but I think one could do better. I was thinking of looking at some of the ideas that the Tweenlite library for AS3 offers. A call to the tweener could look something like this:

ofxTweener::to ( [tms time in ms], [ptw pointer to tweening function], [pf pointer to float], [f float] );

This call would tween the float which the pointer pf is pointing to to the new value the float f defines in tms milliseconds using the ptw tweening function. I guess one would have to call an update function in the ofxTweener class from the main update routine so that the tweener could work this way.

I’ve been reading about an event system to be integrated into of sometime soon, I think that would probably work really well together with my proposed ofxTweener.

My actual question is, would anybody apreciate me putting work into the ofxTweener class, and does my proposed functionality make sense to everyone?



sure ! sounds useful and it makes sense… Have you seen this tweening code:


from erik sjodin ? it might be just what you are asking about or a good starting point:


  • z

Hope I’m not to late :slight_smile:

I second this… it would be really nice to have a simple tweening library similar to how AS3 has Tweener or Tweenlite. However to work similar to Flash using the poco events in 0.0.6 would be best to target the specific object, Also ofxInteractiveObject might be a good library to look at.

Some functions Tweenlite has build in would be really useful such as function proxies and delayed function calls etc.


sometime ago i adapted erik’s code to be more openframeworks style, you can download it here:

but i think it has some events in it based in the event system in 5.7xx so i’ll try to change it to make it more 006. but if you want to take a look…

Hey arturo,

I was wondering if you changed the event system to 006?

Thank you :slight_smile:

yes, indeed i’ve been working with it lately, has made it also easier to use but need to polish it a bit and put an example. will upload tomorrow.

sorry arturo for bothering again, but I would love to use the tweener addon for a multitouch project for university right now and it’s pretty urgant in terms of time so I was wondering if you are done with it or could upload the unpolished version :slight_smile:

thank you very much!

oh sorry! totally forgot… going to pack it and upload.

EDIT: there it is :slight_smile:


hi arturo, great work! oF rules again!!

Maybe you can upload your addon to google code?

[quote author=“arturo”]oh sorry! totally forgot… going to pack it and upload.

EDIT: there it is :)[/quote]

Hey Arturo

I’m trying to build in codeblocks windows and i get the following build errors:

C:\openframeworks\v0.06\addons\ofxTween\src\ofxTween.h|59|error: uint' does not name a type| C:\openframeworks\v0.06\addons\ofxTween\src\ofxTween.h|60|error:uint’ has not been declared|
C:\openframeworks\v0.06\addons\ofxTween\src\ofxTween.h|60|error: ISO C++ forbids declaration of duration' with no type| C:\openframeworks\v0.06\addons\ofxTween\src\ofxTween.cpp|87|error: variable or fieldsetDuration’ declared void|
C:\openframeworks\v0.06\addons\ofxTween\src\ofxTween.cpp|87|error: int ofxTween::setDuration' is not a static member ofclass ofxTween’|
C:\openframeworks\v0.06\addons\ofxTween\src\ofxTween.cpp|87|error: uint' was not declared in this scope| C:\openframeworks\v0.06\addons\ofxTween\src\ofxTween.cpp|87|error: expected,’ or ;' before '{' token| C:\openframeworks\v0.06\addons\ofxTween\src\ofxTween.cpp|91|error:uint’ does not name a type|

seems it doesn’t like uint


yes uint is a typedef or something like that, that doesn’t exist in windows. just substitute all of them with unsigned. will change it and re-upload as soon as i have time.

do you mean instead of
uint getDuration();

unsigned in getDuration();


yes, instead of:

uint getDuration();

unsigned getDuration();

unsigned is actually the same as unsigned int.

Hey arturo,

Thanks a lot for this class
coming from a Flash background I’m going to find it very useful



Hi Arturo,

I’m currently using ofxTween. It’s really helpful.
I had some problems using it, but I found a simple solution.

I think that the boolean ‘running’ should be initialized at false in the constructor of the class ofxTween.

	duration = 0;  
	completed = true;  
	running = false;  
	easingFunction = NULL;  
	from = 0;  
	to = 0;  
	pTarget = 0;  
	easing = NULL;  
	id = -1;  



i made a install.xml file for this as I was having a few small problems that the install.xml fixed. Ive moved the src up a level so that it sits in ofxTween/src instead of ofxTween/ofxTween/src

author & version info needs to be added.



hey everyone,

I’m raising this post from the dead to mention that i’ve extended ofxTween so that you can use it like ofMap, but have tweened values.

I’ve added a static map() function to the existing ofxTween that acts just like ofMap (give it an input min/max, get an output min/max) but also lets you supply an easing equation and type.

there’s a fork of arturo’s original tween in my github at:

included there is an xcode project with an example showing how to use the new mapping function.

This is useful when animating values with things other than time (for example the mouse position, or any other value) where you’d want something more elegant than linear mapping with ofMap. it also doesn’t require creating tween objects at all, which can be more convenient some times.

Hope some others can find it useful as well!

thats great! definitely will come handy.

have just pulled obviousjim changes to my repo, and added a framebased animation flag

Cheers arturo.
Much appreciated