We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello folks, I'm working on a very basic thing: I'd like to increase the size of an ellipse from a very tiny point to fill all the display window. This should happen in 20 minutes. The code I've attached below it works but so far I control the increase with the value of the variable rMove1 and I'd like to do it using something with time, since It should happen in 20 minutes exactly. I'm a newbie and I'm pretty sure there's an easy way to do it. Thank you in advance!
float radius1 = 1;
float rMove1 = 0.001;
int xPos1 = 200;
int yPos1 = 200;
void setup()
{
size(400, 400);
frameRate(30);
}
void draw()
{
background(0);
fill(255);
noStroke();
ellipse(xPos1, yPos1, radius1, radius1);
radius1 += rMove1;
}
Answers
We can call millis() in order to get how many milliseconds have transpired since sketch began:
https://processing.org/reference/millis_.html
Then map() that range to width (or height) range in order to determine current diameter:
https://processing.org/reference/map_.html