Created
February 7, 2015 15:52
-
-
Save zeroeth/94e103703b92c117322d to your computer and use it in GitHub Desktop.
animation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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