We are about to switch to a new forum software. Until then we have removed the registration on this forum.
/**
* shows how to seek a sequence of animations in time
*
* MOUSE[]()
* drag : move from left to right to seek the sequence
*
* KEYS
* space : toggle, pause and resume sequence
* s : start or restart sequence
*/
import de.looksgood.ani.*;
float x, y, diameter;
Table locatoinTable;
int rowCount;
AniSequence seq;
void setup() {
size(512,512);
smooth();
noStroke();
textAlign(CENTER);
locatoinTable = loadTable("sleepy.csv");
int A1 = locatoinTable.getInt(0,0);
int A2 = locatoinTable.getInt(1,0);
x = 50;
y = 50;
diameter = 500; //size of the isotype
// Ani.init() must be called always first!
Ani.init(this);
// create a sequence
seq = new AniSequence(this);
seq.beginSequence();
/////////////////////////////////////////////////////////////under here/////////
seq.beginStep(); //if you want to change the size you have to type this command and also endStep().
seq.add(Ani.to(this, A1, "diameter", 1)); // (this,time(time after tranformation),first size, next size of the isotype)
seq.endStep();
seq.beginStep();
seq.add(Ani.to(this, A2, "diameter",100));
seq.endStep();
seq.add(Ani.to(this, 1, "x:450,y:400"));
seq.add(Ani.to(this, 1, "x:100,y:450"));
seq.beginStep();
seq.add(Ani.to(this, 1, "x:50,y:50"));
seq.add(Ani.to(this, 2, "diameter", 5));
seq.endStep();
///////////////////////////////////////////////below here////////////////
seq.endSequence();
seq.start();
println("total length of this sequence: "+seq.getDuration());
}
void draw() {
background(255);
// calc seek value
if (mousePressed == true) {
float seekValue = mouseX/(float)width;
seq.seek(seekValue);
}
fill(0);
ellipse(x,y,diameter,diameter);
text((int)x+" "+(int)y ,x,y+diameter); //this is for the text message under the circles.
if (seq.isEnded()) println("done");
else println("current time: "+seq.getTime()+" current step: "+seq.getStepNumber()+" of "+seq.getStepCount());
}
// pause
void mousePressed() {
seq.pause();
}
// resume
void mouseReleased() {
seq.resume();
}
// pause and resume animation by pressing SPACE
// or press "s" to start/restart the sequence
void keyPressed() {
if (key == 's' || key == 'S') seq.start();
if (key == ' ') {
if (seq.isPlaying()) seq.pause();
else seq.resume();
}
}
this is the ani library example.
at that part(which I indicated in the middle of the code), I want to control the x,y position. I know how to do it, when the subject is static. but when I want to set the position at that "diameter"line, it doesn't work....
Is there a way to change the position of the subject?
I saw other ani examples also... but nothing was able to change it...
or ani library just sets the position at the first time?
ughh...
It's driving me crazy.
Answers
Oh I just need to edit the x,y variables...It's just a simple problem.
If you need to look further about it, there's this thread too: ;)
http://forum.processing.org/two/discussion/4416/moving-circles-at-different-speed-when-scroll-using-ani