We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
growing ellipse (Read 295 times)
growing ellipse
Nov 11th, 2008, 1:00pm
 
hello

i have got a ellipse.
this ellipse should grow once only.
but this ellipse grows always.
void setup() {
 size(300,300);
}

void draw() {
 int d=((millis()/100) % 20)+4;
 ellipse(150,150,d,d);
}
Re: growing ellipse
Reply #1 - Nov 12th, 2008, 7:31am
 
Modulo (%) is made to cycle between two values.
If you want to stop at a given value, you have to make a test:
Code:
final static int MAX_SIZE = 24;

void setup() {
size(300, 300);
}

void draw() {
int d = 4 + millis()/100;
if (d > MAX_SIZE) d = MAX_SIZE;
ellipse(150, 150, d, d);
}
Page Index Toggle Pages: 1