# Constant ellipse when mouse clicked

**URL:** <https://discourse.processing.org/t/constant-ellipse-when-mouse-clicked/21014>\
**Category:** Beginners\
**Tags:** homework\
**Created:** [May 18, 2020, 1:06pm UTC](https://discourse.processing.org/t/constant-ellipse-when-mouse-clicked/21014 "2020-05-18T13:06:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Casto92i](https://avatars.discourse-cdn.com/v4/letter/c/82dd89/32.png) [@Casto92i](https://discourse.processing.org/u/Casto92i)\
**Post date:** [May 18, 2020, 1:06pm UTC](https://discourse.processing.org/t/constant-ellipse-when-mouse-clicked/21014/1 "2020-05-18T13:06:08Z")

</div>

```auto
void mousePressed(){
    ellipse(Projpos.x, Projpos.y, 100, 100);
}

```

Hi, i have a problem where i’d like to spawn an ellipse each time the mouse is pressed but when i pressed my mouse an ellipse spawn just for 1 second

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [May 18, 2020, 1:15pm UTC](https://discourse.processing.org/t/constant-ellipse-when-mouse-clicked/21014/2 "2020-05-18T13:15:37Z")

</div>

Hi,

Welcome to the community! 🙂

The thing to remember is that the `draw()` function is being executed roughly 60 times per second. So if each time you draw a white background like this :

```auto
void draw(){
  // White background
  background(255);
}

```

then you are going to clear the window each frame. It means that if you draw an ellipse when you press your mouse, it’s going to disappear next frame.

You have two solutions :

- You can remove the `background(255);` instruction in the `draw` function and put it in the `setup` function so it’s only going to draw a white background at the beginning of the sketch and your ellipses are going to stay printed on the screen. It’s not the best solution because it means that everything that you draw is going to stay on the screen…

- The second solution is more adaptable : you need to store the position of your ellipses in an array each time you press the mouse and then each frame re-draw those ellipses.  
I suggest you use [ArrayList](https://processing.org/reference/ArrayList.html) to store some [PVector](https://processing.org/reference/PVector.html) representing the locations of your ellipses.
