Trying to make a shape grow on its own

Hi, I’m very very new to Processing (just learned loops earlier today) and am trying to figure something out. I’m trying to make it so that when you click the screen, a circle of random size and colour shows up, and then grows indefinitely at a set speed (preferably a random speed for each one) after being placed. I’ve got it to a point where the circles appear on click and are of a random size/colour, but I don’t know how to make them grow by themselves. Below is the code I have so far.

I’m sure this is a very simple question but I’ve been struggling with this and would appreciate any help :pray:

float circleX;

void setup() {
size(1000,1000);
background(0);
}

void draw() {
circleX = random(0,220);
}

void mousePressed() {
fill(random(255),random(255),random(255));
ellipse(mouseX,mouseY,circleX,circleX);
}

You will need more variables to track different things your code knows about your circles.

You will need three float variables for the X position, Y position, and size of the circle. Name these variables properly!

You will need a color variable for the circle’s color.

You might need a boolean to know if the circle should be drawn.

Next, draw the circle. Just draw it. Use the values in those four variables you just made. Try to change each of them to see how that changes what the circle looks like.

Now add logic that increases the size of the circle each time draw() happens. What happens to your circle now?

When the mouse is pressed, you’ll want to change some of the values in your variables. You will need a random position. You will need a new, smaller, random size. You will need a random color.

Your code should follow this format:

float ???, ???, ???;
color ???;
boolean draw_circle;

void setup(){
  size(1000,1000);
  draw_circle = false;
}

void draw(){
  if( ??? ){
    fill( ??? );
    ellipse( ???, ???, ???, ??? );
    ??? = ??? + 1;
  }
}

void mousePressed(){
  draw_circle = true;
  ??? = random( ??? );
  ??? = random( ??? );
  ??? = random( ??? );
  ??? = color( random( 255 ), random( 255 ), random( 255 ) );
}
1 Like

Hello,

There are tutorials, resources and examples here:

Every time I peruse them I learn something new.

:)