Why is this happening? (picture)

edited May 2014 in Library Questions

Screen Shot 2014-05-18 at 10.30.40 PM Screen Shot 2014-05-18 at 10.30.46 PM

I write this animation (ani.library) code.

But the probelm is the 3 objects are moving up and down... It's weird because I set the x,y position correctly.

In my opinion this thing is related to the working flow.

Anyway here is the code. Since, I didn't use the for loop it's very long.

I copy and paste only one object code because it's too long.

Need some advice

/**
 * 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;
float delay = 0.5;
PImage img; // this is for the importing the image
float scaler = 0.001;
float diameter = 10; //size of the subject
float diameter2 = 10; //don't know what this is for
float diameter3 = 10;

///////////////////////////////////////////////

float[] Productive = {
  90281*scaler, 
  90790*scaler, 
  91348*scaler, 
  91890*scaler, 
  92352*scaler, 
  92644*scaler, 
  92731*scaler, 
  92650*scaler, 
  92398*scaler, 
  91977*scaler, 
  91397*scaler, 
  90681*scaler, 
  89846*scaler, 
  88762*scaler, 
  87624*scaler, 
  86535*scaler, 
  85365*scaler, 
  84200*scaler, 
  83115*scaler, 
  82047*scaler, 
  80791*scaler, 
  79475*scaler, 
  78267*scaler, 
  77047*scaler, 
  75868*scaler, 
  74778*scaler, 
  73785*scaler, 
  72870*scaler, 
  72002*scaler, 
  71122*scaler, 
  70146*scaler, 
  69057*scaler, 
  67922*scaler, 
  66845*scaler, 
  65901*scaler, 
  65103*scaler, 
  64420*scaler, 
  63785*scaler, 
  63153*scaler, 
  62516*scaler, 
  61838*scaler, 
  61081*scaler, 
  60222*scaler, 
  59278*scaler, 
  58281*scaler, 
  57273*scaler, 
  56267*scaler
}; 


//////////////////////////////////////////



AniSequence seq;
AniSequence seq2; //this sequence is for the Old population
AniSequence seq3; //this sequence is for the population of infants 6-14

void setup() {
  size(1400,720);
  smooth();
  noStroke();
  textAlign(CENTER);
  img = loadImage("background.jpg"); //import the image file

  x = 100;
  y = 100;

  // Ani.init() must be called always first!
  Ani.init(this);

///////////////////////sequence for the Productive population///////////////////
  // create a sequence
  seq = new AniSequence(this);
  seq.beginSequence();


  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[0])); // (this,time(time after tranformation),first size, next size)
  seq.add(Ani.to(this, delay, "x:300,y:400"));
  seq.endStep();

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[1]));
  seq.add(Ani.to(this, delay, "x:320,y:400"));
  seq.endStep();

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[2]));
  seq.add(Ani.to(this, delay, "x:340,y:400"));
  seq.endStep();

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[3]));
  seq.add(Ani.to(this, delay, "x:360,y:400"));
  seq.endStep();

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[4]));
  seq.add(Ani.to(this, delay, "x:380,y:400"));
  seq.endStep();

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[5]));
  seq.add(Ani.to(this, delay, "x:400,y:400"));
  seq.endStep();

    seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[6]));
  seq.add(Ani.to(this, delay, "x:420,y:400"));
  seq.endStep();  

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[7]));
  seq.add(Ani.to(this, delay, "x:440,y:400"));
  seq.endStep();  

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[8]));
  seq.add(Ani.to(this, delay, "x:460,y:400"));
  seq.endStep();  

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[9]));
  seq.add(Ani.to(this, delay, "x:480,y:400"));
  seq.endStep();  

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[10]));
  seq.add(Ani.to(this, delay, "x:500,y:400"));
  seq.endStep();  

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[11]));
  seq.add(Ani.to(this, delay, "x:520,y:400"));
  seq.endStep();  

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[12]));
  seq.add(Ani.to(this, delay, "x:540,y:400"));
  seq.endStep();  

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[13]));
  seq.add(Ani.to(this, delay, "x:560,y:400"));
  seq.endStep();  

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[14]));
  seq.add(Ani.to(this, delay, "x:580,y:400"));
  seq.endStep();  

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[15]));
  seq.add(Ani.to(this, delay, "x:600,y:400"));
  seq.endStep();  

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[16]));
  seq.add(Ani.to(this, delay, "x:620,y:400"));
  seq.endStep();  

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[17]));
  seq.add(Ani.to(this, delay, "x:640,y:400"));
  seq.endStep();  

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[18]));
  seq.add(Ani.to(this, delay, "x:660,y:400"));
  seq.endStep();  

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[19]));
  seq.add(Ani.to(this, delay, "x:680,y:400"));
  seq.endStep();  

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[20]));
  seq.add(Ani.to(this, delay, "x:700,y:400"));
  seq.endStep();  

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[21]));
  seq.add(Ani.to(this, delay, "x:720,y:400"));
  seq.endStep();

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[22]));
  seq.add(Ani.to(this, delay, "x:740,y:400"));
  seq.endStep();

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[23]));
  seq.add(Ani.to(this, delay, "x:760,y:400"));
  seq.endStep();

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[24]));
  seq.add(Ani.to(this, delay, "x:780,y:400"));
  seq.endStep();

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[25]));
  seq.add(Ani.to(this, delay, "x:800,y:400"));
  seq.endStep();

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[26]));
  seq.add(Ani.to(this, delay, "x:820,y:400"));
  seq.endStep();

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[27]));
  seq.add(Ani.to(this, delay, "x:840,y:400"));
  seq.endStep();

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[28]));
  seq.add(Ani.to(this, delay, "x:860,y:400"));
  seq.endStep();

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[29]));
  seq.add(Ani.to(this, delay, "x:880,y:400"));
  seq.endStep();

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[30]));
  seq.add(Ani.to(this, delay, "x:900,y:400"));
  seq.endStep();

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[31]));
  seq.add(Ani.to(this, delay, "x:920,y:400"));
  seq.endStep();

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[32]));
  seq.add(Ani.to(this, delay, "x:940,y:400"));
  seq.endStep();

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[33]));
  seq.add(Ani.to(this, delay, "x:960,y:400"));
  seq.endStep();

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[34]));
  seq.add(Ani.to(this, delay, "x:980,y:400"));
  seq.endStep();

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[35]));
  seq.add(Ani.to(this, delay, "x:1000,y:400"));
  seq.endStep();

  seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[36]));
  seq.add(Ani.to(this, delay, "x:1020,y:400"));
  seq.endStep();

    seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[37]));
  seq.add(Ani.to(this, delay, "x:1040,y:400"));
  seq.endStep();

    seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[38]));
  seq.add(Ani.to(this, delay, "x:1060,y:400"));
  seq.endStep();

    seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[39]));
  seq.add(Ani.to(this, delay, "x:1080,y:400"));
  seq.endStep();

    seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[20]));
  seq.add(Ani.to(this, delay, "x:1100,y:400"));
  seq.endStep();

    seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[41]));
  seq.add(Ani.to(this, delay, "x:1120,y:400"));
  seq.endStep();

    seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[42]));
  seq.add(Ani.to(this, delay, "x:1140,y:400"));
  seq.endStep();

    seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[43]));
  seq.add(Ani.to(this, delay, "x:1160,y:400"));
  seq.endStep();

    seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[44]));
  seq.add(Ani.to(this, delay, "x:1180,y:400"));
  seq.endStep();

      seq.beginStep();
  seq.add(Ani.to(this, delay, "diameter", Productive[45]));
  seq.add(Ani.to(this, delay, "x:1200,y:400"));
  seq.endStep();

  seq.endSequence();
  seq.start();

 // println("total length of this sequence: "+seq.getDuration());

  //////////////////////////////////////////////////////////////////


  //////////////////////////start sequence of the Aging population///////

}

void draw() {
  background(255);
   image(img, 0, 0);
  // calc seek value
  if (mousePressed == true) {
    float seekValue = mouseX/(float)width;
    seq.seek(seekValue);
    seq2.seek(seekValue);
    seq3.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.


//  println("done");
//  else println("current time: "+seq.getTime()+"  current step: "+seq.getStepNumber()+" of "+seq.getStepCount());
//
//

}
// pause
void mousePressed() {
  seq.pause();
  seq2.pause();
  seq3.pause();
}

// resume
void mouseReleased() {
  seq.resume();
  seq2.resume();
  seq3.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();
      seq2.start();
         seq3.start();
 }

  if (key == ' ') {
    if (seq.isPlaying()) seq.pause();
    else seq.resume();
  }

    if (key == ' ') {
    if (seq2.isPlaying()) seq2.pause();
    else seq2.resume();
  }

    if (key == ' ') {
    if (seq3.isPlaying()) seq3.pause();
    else seq3.resume();
  }
}
Tagged:

Answers

Sign In or Register to comment.