Ok some more feedbacks :
* Maybe add a fourth parameter, easingFunction, that defaults to the identity function ( x => x ).
* you might implement all this using a pure javascript class.
* In fact,
if you handle only numbers, there's even a nicer way to handle the value : overload the valueOf() object method.
Just add ValueOf in the methods and have it return the same as value property.
But what is ValueOf() ??
--> When Javascript expects a number and encounter an object, it will try to get its value using the valueOf() method :
expl : if (object == 2) ...
expl2 : drawImage(image, xCoordObject, yCoordObject);
The default value returned is -expectedly- NaN.
For strings, the value returned is parseFloat(this).
So if you do this with your object, the way to use it will become :
// in the init or after a given event...
this.xCoord = new ig.Interpolation(100, 200, 5);
// in the draw...
ctx.drawImage ( someImage, this.xCoord, 20);
the example above will have the image move on an horizontal line from 100 to 200 in 5 seconds.
the only issue with this way of dealing with the value is that you (or the framework)
might easily 'break' the object by assigning a value to it :
say xCoord's value is 150 now. if you do :
this.xCoord++;
then you have this.xCoord === 151 (as expected), but it is === to 151, not ==, meaning it won't move a step further : you replaced the interpolation object with the number 151.
You might, for instance, set, in an entity, this.pos.x to an interpoler, but then do not call this.parent() in the update, or the move (this.pos.x += delta * this.vel.x ), will 'kill' the interpoler.
Still i think it is an interesting way to provide access to the value.