b-g / Ani

A lightweight animation library for the programming environment Processing
79 stars 13 forks source link

Loop bug when delay is > 0 for first item in a sequence #8

Open hamoid opened 10 years ago

hamoid commented 10 years ago

When creating a looped sequence, something seems to go wrong if the first item in the sequence has a delay. The issue is not present if other items in the sequence have delays.

Also, only the first variable is affected. In this case it affects only x, but not y or sz.

What seems to happen is, when running seq.start(), the first variable suddenly jumps to the value it should have in the second sequence step (150 instead of 50 in this case).

import de.looksgood.ani.*;

AniSequence seq;
float x=100, y=150, sz=60;

void setup() {
  size(600, 600, P2D);

  // if delayBug is greater than 0, something goes wrong
  float delayBug = 0.0;

  Ani.init(this);
  seq = new AniSequence(this);
  seq.beginSequence();
  seq.add(Ani.to(this, 1, delayBug, "x:50.,y:50,sz:40", Ani.QUAD_IN_OUT ));
  seq.add(Ani.to(this, 1, 1.0, "x:150,y:50,sz:20", Ani.QUAD_IN_OUT ));
  seq.add(Ani.to(this, 1, 1.0, "x:100,y:150,sz:60", Ani.QUAD_IN_OUT, "onEnd:seqEnd"));    
  seq.endSequence();
  seq.start();
}

void draw() {
  background(255);
  ellipse(x, y, sz, sz);
  println(x, y, sz);
}

void seqEnd() {
  println("start");
  seq.start();
}
b-g commented 10 years ago

hi @hamoid, many thanks for reporting! will look into it as soon i have time for it ... might take a while as i will be busy traveling in california in the next few weeks. best, b