Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
animation
import de.looksgood.ani.*;
float x, y, diameter;
AniSequence sequence;
void setup() {
size(512,512);
smooth();
noStroke();
textAlign(CENTER);
background(255);
x = 50;
y = 50;
diameter = 10;
Ani.init(this);
sequence = new AniSequence(this);
sequence.beginSequence();
sequence.add(Ani.to(this, 1, "diameter:55"));
sequence.add(Ani.to(this, 2, "x:400, y:100"));
sequence.add(Ani.to(this, 1, "x:450, y:400"));
// do two things at once
sequence.beginStep();
sequence.add(Ani.to(this, 2, "x:50, y:50"));
sequence.add(Ani.to(this, 1, "diameter:5"));
sequence.endStep();
sequence.endSequence();
// start the animation
sequence.start();
}
void draw() {
// Draw semi transparent to 'fade'
fill(255,5);
rect(0,0,width,height);
fill(random(255), random(255), random(255));
translate(x,y);
scale(diameter);
ellipse(0,0,1,1);
if(sequence.isEnded())
{
sequence.start();
}
}
// pause and resume animation by pressing SPACE
// or press "s" to start the sequence
void keyPressed() {
if (key == 's' || key == 'S') sequence.start();
if (key == ' ') {
if (sequence.isPlaying()) sequence.pause();
else sequence.resume();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment