Skip to content

Instantly share code, notes, and snippets.

@zeroeth
Created February 7, 2015 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeroeth/94e103703b92c117322d to your computer and use it in GitHub Desktop.
Save zeroeth/94e103703b92c117322d to your computer and use it in GitHub Desktop.
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