The shaper class is abstract and intended to be extended in order to create custom shape functions.
These extended shape functions can then be passed to Tween constructors, or setEasing()
to set the easing for these tweens. The extended class must implement the f(x) method
as shown below.
public class SquareShaper extends Shaper{
public float f( float x ){
return x*x;
}
}
In order to use the custom shape function with the Tween, pass in an instance of the
custom class to setEasing().
import megamu.shapetween.*
Tween ani;
void setup(){
shape = new SquareShaper();
ani = new Tween(this, 2);
ani.setEasing( shape );
}
void draw(){
background(255);
ellipse(ani.time()*width, ani.position()*width, 4, 4);
}
void mousePressed(){
ani.setShape( new OtherCustomShaper() );
}