# Expanding circles, how do I do it?

**URL:** https://discourse.processing.org/t/expanding-circles-how-do-i-do-it/9305
**Category:** Coding Questions
**Created:** [March 14, 2019, 6:04pm UTC](https://discourse.processing.org/t/expanding-circles-how-do-i-do-it/9305 "2019-03-14T18:04:57Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![fraxinus](https://avatars.discourse-cdn.com/v4/letter/f/c89c15/32.png) [@fraxinus](https://discourse.processing.org/u/fraxinus)
#### Post date: [March 14, 2019, 6:04pm UTC](https://discourse.processing.org/t/expanding-circles-how-do-i-do-it/9305/1 "2019-03-14T18:04:57Z")

</div>

How do I make a circle that starts as a dot and then keeps getting bigger until it disappears?  
Also then, how would I have more circles continuously appearing from that same point one after the other so I get what looks like a wave expanding in all directions viewed from above?

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [March 14, 2019, 6:10pm UTC](https://discourse.processing.org/t/expanding-circles-how-do-i-do-it/9305/2 "2019-03-14T18:10:45Z")

</div>

Hello and welcome here!

Please read this and build your animation from here:

[https://www.processing.org/tutorials/overview/](https://www.processing.org/tutorials/overview/)

Look at ellipse to get started:

[https://www.processing.org/reference/ellipse\_.html](https://www.processing.org/reference/ellipse_.html)

you need to store width and height of the ellipse. Use a variable **d** for both

increase **d** : d=d+1;

then show your animation sketch so far

Chrisir

---

<div class="post-metadata">

### Author: ![fraxinus](https://avatars.discourse-cdn.com/v4/letter/f/c89c15/32.png) [@fraxinus](https://discourse.processing.org/u/fraxinus)
#### Post date: [March 14, 2019, 6:40pm UTC](https://discourse.processing.org/t/expanding-circles-how-do-i-do-it/9305/3 "2019-03-14T18:40:01Z")

</div>

Thanks!

Here is my progress so far:

float d = 1;

void setup() {  
size(640, 360);  
stroke(255, 204, 0);  
noFill();  
}

void draw() {

background(0);  
d = (d+1);  
ellipse(200, 200, d, d);

}

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [March 14, 2019, 7:22pm UTC](https://discourse.processing.org/t/expanding-circles-how-do-i-do-it/9305/4 "2019-03-14T19:22:06Z")

</div>

nicely done!

Remember to hit **ctrl-t** in processing to get auto-format (indents)

**Next step**

Now, you want to have different circles with same center

This calls for arrays!

an Array is a list of values.

so before `setup()`:

```auto
int[] ds = new int[1000]; // wrong! d, not ds ;-)
int timer;
int max=0; 

```

in `draw()`:

```auto
for(int i = 0; i<max; i++) {
     ellipse ( 200,200, d[i], d[i] ); 
     d[i]=d[i]+1; 
}

if(millis()-timer>1400) {
     max=max+1; 
     timer = millis(); 
}

```

Chrisir 😉

---

<div class="post-metadata">

### Author: ![fraxinus](https://avatars.discourse-cdn.com/v4/letter/f/c89c15/32.png) [@fraxinus](https://discourse.processing.org/u/fraxinus)
#### Post date: [March 14, 2019, 7:47pm UTC](https://discourse.processing.org/t/expanding-circles-how-do-i-do-it/9305/5 "2019-03-14T19:47:33Z")

</div>

I got this error. What does it mean?

 ![2019-03-14](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/6/6469cd5f2ec7ba74d83f66ada29a1fc5e42a3aa9.png)

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [March 14, 2019, 7:49pm UTC](https://discourse.processing.org/t/expanding-circles-how-do-i-do-it/9305/6 "2019-03-14T19:49:46Z")

</div>

please hit **ctrl-t** in processing  
please post your entire code as text

Do you have this:

```auto
int[] d = new int[1000]; 

```

(I had `ds` there falsely)

---

<div class="post-metadata">

### Author: ![fraxinus](https://avatars.discourse-cdn.com/v4/letter/f/c89c15/32.png) [@fraxinus](https://discourse.processing.org/u/fraxinus)
#### Post date: [March 14, 2019, 7:52pm UTC](https://discourse.processing.org/t/expanding-circles-how-do-i-do-it/9305/7 "2019-03-14T19:52:12Z")

</div>

ah, I removed the s and now it’s working. Cool!! Thank you so much!

Here is the code so far:

```auto
int[] d = new int[1000]; 
int timer;
int max=0; 

void setup() {
  size(1500, 700);
}

void draw() {

  background(220);
  stroke(0);
  fill(0);
  rect(100, 100, 300, 400);
  noFill();
  stroke(255, 100, 0);
  //ellipse(200, 200, d, d);
  //d=d+5;

  for (int i = 0; i<max; i++) {
    ellipse ( 200, 200, d[i], d[i] ); 
    d[i]=d[i]+1;
  }

  if (millis()-timer>1400) {
    max=max+1; 
    timer = millis();
  }
}

```

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [March 14, 2019, 7:57pm UTC](https://discourse.processing.org/t/expanding-circles-how-do-i-do-it/9305/8 "2019-03-14T19:57:59Z")

</div>

well done!

please read the code and understand

- arrays,
- timer and
- why we get slowly more circles.

The sketch will crash after a few minutes. How many? Why?

What does `max` do?

**Auto-Format in processing**

hit **ctrl-t** in processing (or menue **Edit | Auto-format** )

**Formatting in the Forum**

Anyway, in the forum after pasting, please mark your code with the mouse and click `</>` in the command bar

- to show your code formatted as code when posting in the forum

Chrisir 😉

---

<div class="post-metadata">

### Author: ![fraxinus](https://avatars.discourse-cdn.com/v4/letter/f/c89c15/32.png) [@fraxinus](https://discourse.processing.org/u/fraxinus)
#### Post date: [March 14, 2019, 8:05pm UTC](https://discourse.processing.org/t/expanding-circles-how-do-i-do-it/9305/9 "2019-03-14T20:05:26Z")

</div>

Will do!

Thanks!! 😄
