I am using Processing language to sketch a rectangle that grows in size with time. Following code is not giving any output.
void setup()
{
size(900,900);
}
void draw()
{
int edge=100;
for(int i=0;i<300;i++)
{
delay(100);
edge++;
rect(100,100,edge,edge);
}
}
I suspect having wrongly used delay() function.
Here is one such "roll your own" delay method which is good for most purposes. Just change the values passed into the delay method to alter the timing. This just outputs "start" and "end" roughly every 2 seconds for example.
void draw()
{
System.out.println("start");
delay(2000);
System.out.println("end");
delay(2000);
}
void delay(int delay)
{
int time = millis();
while(millis() - time <= delay);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With