Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3 new examples, documentation re-generated
- Loading branch information
Benedikt Groß
committed
Oct 8, 2012
1 parent
74a8b67
commit 3dfaa77
Showing
45 changed files
with
376 additions
and
130 deletions.
There are no files selected for viewing
Binary file not shown.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/** | ||
* shows how to loop a whole sequence | ||
* | ||
* KEYS | ||
* space : toggle, pause and resume sequence | ||
* s : start or restart sequence | ||
*/ | ||
|
||
import de.looksgood.ani.*; | ||
|
||
float x, y, diameter; | ||
AniSequence seq; | ||
|
||
void setup() { | ||
size(512,512); | ||
smooth(); | ||
noStroke(); | ||
textAlign(CENTER); | ||
background(255); | ||
|
||
x = 50; | ||
y = 50; | ||
diameter = 10; | ||
|
||
// Ani.init() must be called always first! | ||
Ani.init(this); | ||
|
||
// create a sequence | ||
// dont forget to call beginSequence() and endSequence() | ||
seq = new AniSequence(this); | ||
seq.beginSequence(); | ||
|
||
// step 0 | ||
seq.add(Ani.to(this, 1, "diameter", 55)); | ||
|
||
// step 1 | ||
seq.add(Ani.to(this, 2, "x:400,y:100")); | ||
|
||
// step 2 | ||
seq.add(Ani.to(this, 1, "x:450,y:400")); | ||
|
||
// step 3 | ||
seq.add(Ani.to(this, 1, "x:100,y:450")); | ||
|
||
// step 4 | ||
seq.beginStep(); | ||
seq.add(Ani.to(this, 1, "x:50,y:50")); | ||
seq.add(Ani.to(this, 2, "diameter", 5, Ani.EXPO_OUT, "onEnd:sequenceEnd")); | ||
seq.endStep(); | ||
|
||
seq.endSequence(); | ||
|
||
// start the whole sequence | ||
seq.start(); | ||
} | ||
|
||
void draw() { | ||
fill(255,5); | ||
rect(0,0,width,height); | ||
|
||
//println(seq.isFinished()); | ||
|
||
fill(0); | ||
ellipse(x,y,diameter,diameter); | ||
} | ||
|
||
void sequenceEnd() { | ||
//println("sequenceEnd() restart all again"); | ||
seq.start(); | ||
} | ||
|
||
// pause and resume animation by pressing SPACE | ||
// or press "s" to start the sequence | ||
void keyPressed() { | ||
if (key == 's' || key == 'S') seq.start(); | ||
if (key == ' ') { | ||
if (seq.isPlaying()) seq.pause(); | ||
else seq.resume(); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
72 changes: 72 additions & 0 deletions
72
examples/Ani_Workaround_Android/Ani_Workaround_Android.pde
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* This example is a workaround to get Ani running on android. | ||
* Basically the example mimics the registerPre() mechanism (to hook into | ||
* the draw loop from a library). Unfortunatelly registerPre() is not | ||
* available at processing for android. This sketch is a hack to get around | ||
* this issue: More infos here: | ||
* | ||
* http://wiki.processing.org/w/Android#API_Changed.2C_Gone.2C_or_Forgotten | ||
* https://forum.processing.org/topic/android-api-changes-registering-methods-make-library-also-working-on-android | ||
* https://github.com/b-g/Ani/issues/1#issuecomment-4799082 | ||
*/ | ||
|
||
import de.looksgood.ani.*; | ||
|
||
float x = 256; | ||
float y = 256; | ||
|
||
ArrayList<Ani> anis; // workaround | ||
ArrayList anisToUnregister; // workaround | ||
|
||
void setup() { | ||
size(512, 512); | ||
smooth(); | ||
noStroke(); | ||
|
||
Ani.init(this); | ||
|
||
anis = new ArrayList<Ani>(); // workaround | ||
anisToUnregister = new ArrayList(); // workaround | ||
} | ||
|
||
void draw() { | ||
background(255); | ||
fill(0); | ||
ellipse(x, y, 120, 120); | ||
|
||
updateAnis(); // workaround | ||
} | ||
|
||
void mouseReleased() { | ||
Ani.to(this, 1.5, "x", mouseX); | ||
Ani.to(this, 1.5, "y", mouseY); | ||
} | ||
|
||
// workaround ------------------------------------------- | ||
void updateAnis(){ | ||
if (anis.size() == 0) return; | ||
|
||
for (int i=0; i < anis.size(); i++) { | ||
Ani aniTmp = (Ani)anis.get(i); | ||
aniTmp.pre(); | ||
} | ||
|
||
if(anisToUnregister.size() > 0) { | ||
for (int i=0; i < anisToUnregister.size(); i++) { | ||
anis.remove(i); | ||
anisToUnregister.remove(i); | ||
println("removed"); | ||
} | ||
} | ||
println(anis.size()); | ||
} | ||
|
||
void registerPre(Object obj) { | ||
anis.add( (Ani)obj ); | ||
} | ||
|
||
void unregisterPre(Object obj) { | ||
int index = anis.indexOf( (Ani)obj ); | ||
anisToUnregister.add(index); | ||
} | ||
// workaround ------------------------------------------- |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* shows how to use Ani in your own classes and | ||
* how to trigger/bang an animation (via keyboard). | ||
* | ||
* KEYS | ||
* space : bang the circle | ||
*/ | ||
|
||
import de.looksgood.ani.*; | ||
|
||
Cirlce cirlce; | ||
|
||
void setup() { | ||
size(512, 512); | ||
smooth(); | ||
noStroke(); | ||
textAlign(CENTER); | ||
|
||
// Ani.init() must be called always first! | ||
Ani.init(this); | ||
cirlce = new Cirlce(); | ||
} | ||
|
||
void draw() { | ||
background(255); | ||
cirlce.draw(); | ||
} | ||
|
||
void keyReleased() { | ||
if (key == ' ') cirlce.bang(); | ||
} | ||
|
||
class Cirlce { | ||
float x = random(0, width); | ||
float y = random(0, height); | ||
color c = color(0); | ||
|
||
Ani diameterAni; | ||
float diameterStart = 200; | ||
float diameterEnd = 5; | ||
float diameter = diameterStart; | ||
float duration = 0.9; | ||
|
||
Cirlce() { | ||
// diameter animation | ||
diameterAni = new Ani(this, duration, "diameter", diameterEnd); | ||
diameterAni.pause(); | ||
diameter = diameterEnd; | ||
} | ||
|
||
void bang() { | ||
diameter = diameterStart; | ||
diameterAni.seek(0); | ||
diameterAni.resume(); | ||
} | ||
|
||
void draw() { | ||
fill(c); | ||
ellipse(x, y, diameter, diameter); | ||
} | ||
} | ||
|
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
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
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
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
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
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
Oops, something went wrong.