( back ) Making
an image persist when its animation ends
Sometimes an image should stay at its endpoint. This demo illustrates
one way to accomplish that.
Animation test;
void setup()
{
size(400,100);
test = new Animation(this, loadImage("image.gif"), 100,40, 200,40);
test.setRepetitions(1);
test.setEnd("endMethod");
test.showRectangle();
test.setDuration(10000);
}
void loop()
{
background(127);
test.draw();
}
// alter the Animation so that it makes a linear path in a rectangle
// with width and height 0.
void endMethod()
{
test.setRectangle(test.currentX(),test.currentY(),0,0);
test.setRepetitions(0);
test.reset();
}
|