OK, I will try and illustrate my ideas, recycling a simple sketch I have.
Something like your code:
Code:int rMove = +5;
int slowDown = 1;
int minRadius = 5, maxRadius = 100;
int radius = minRadius;
int xPos = 200;
int yPos = 200;
color c1 = #005599, c2 = #00AA99;
void setup()
{
size(400, 400);
}
void keyPressed()
{
exit();
}
void draw()
{
background(240);
fill(lerpColor(c1, c2, (float) radius / (float) maxRadius));
rMove = -rMove;
for (int radius = minRadius; radius <= maxRadius && radius >= minRadius; radius += rMove)
{
ellipse(xPos, yPos, radius, radius);
delay(1000);
}
}
It doesn't work, we see nothing moving, only a pulsating circle.
Now, if I change the draw code to:
Code:void draw()
{
background(240);
fill(lerpColor(c1, c2, (float) radius / (float) maxRadius));
ellipse(xPos, yPos, radius, radius);
if (frameCount % slowDown == 0)
{
radius += rMove;
if (radius > maxRadius)
rMove = -1;
else if (radius < minRadius)
rMove = +1;
}
}
it is much better, or at least close of what I wanted to do... (there is a strange start up).
If you increase slowDown, you control the speed. We don't spend much time in the draw routine, and the keyPressed routine is active.