Shrinking and Growing Shapes
in
Programming Questions
•
10 months ago
I have a square and a exclipse, the square is shrinking to a certain size and the eclipse is growing to a certain size. I got the shapes to stop at the certain sizes but after they stop I need them to grow to their regular shape and then shrink in a loop.
I also need help trying to make a function where this process can be stopped by touching a key and then resumes by clicking the mouse.
This is the code I have so far..
int circleSize=0;
int radius=0;
int radius2=300;
void setup()
{
size (400,400);
}
int radius=0;
int radius2=300;
void setup()
{
size (400,400);
}
void draw()
{
background(255);
stroke(0);
fill(170);
rectMode(CENTER);
rect(width/2,height/2,radius2,radius2);
radius2--;
fill(0,170,0);
ellipseMode(CENTER);
ellipse(width/2, height/2, radius, radius);
radius++;
smooth();
if (radius2 == 151){
radius2 = 151+1;
}
if (radius == 150){
radius--;
}
}
{
background(255);
stroke(0);
fill(170);
rectMode(CENTER);
rect(width/2,height/2,radius2,radius2);
radius2--;
fill(0,170,0);
ellipseMode(CENTER);
ellipse(width/2, height/2, radius, radius);
radius++;
smooth();
if (radius2 == 151){
radius2 = 151+1;
}
if (radius == 150){
radius--;
}
}
I'm a beginner and I've been trying to figure this out for a little bit, if someone could please help I would appreciate it.
Thanks!
1