# Ellipse appears at 0,0 due to an array, I want it to only appear when mouse is pressed.

**URL:** <https://discourse.processing.org/t/ellipse-appears-at-0-0-due-to-an-array-i-want-it-to-only-appear-when-mouse-is-pressed/15198>\
**Category:** Processing\
**Created:** [November 3, 2019, 4:15pm UTC](https://discourse.processing.org/t/ellipse-appears-at-0-0-due-to-an-array-i-want-it-to-only-appear-when-mouse-is-pressed/15198 "2019-11-03T16:15:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jackattack991](https://avatars.discourse-cdn.com/v4/letter/j/a698b9/32.png) [@jackattack991](https://discourse.processing.org/u/jackattack991)\
**Post date:** [November 3, 2019, 4:15pm UTC](https://discourse.processing.org/t/ellipse-appears-at-0-0-due-to-an-array-i-want-it-to-only-appear-when-mouse-is-pressed/15198/1 "2019-11-03T16:15:51Z")

</div>

```auto
final int N_PARTITIONS = 10;

int Diameter = 10;
int length = 101; // max number of nodes

float [] Node1 = new float [10];
float [] Node2 = new float [10];

void setup() {
background(255);
size(600,360);

}
void draw() {
background(255);
stroke(220,220,220);
for(int i=0; i<height; i=i+(height/N_PARTITIONS)){
line(0,i,width,i); // creates horizontal line for grid
}
for(int i=0; i <width; i=i+(width/N_PARTITIONS)){
line( i,0,i,height); // creates vertical lines for grid
}
stroke(0);
for (int i=0; i<Node1.length; i++)
{
fill (0);
ellipse(Node1[i], Node2[i], Diameter, Diameter); // array for nodes
}
for (int i=0; i<Node1.length-1; i++){
line (Node1[i],Node2[i],Node1[i+1],Node2[i+1]); // creates line connecting nodes

}
line (Node1[0],Node2[0],Node1[Node1.length-1],Node2[Node2.length-1]);
 
}

void mousePressed () { // creates node when mouse is pressed

Node2 = append(Node2, mouseY);

Node1 = append(Node1, mouseX);

}

```

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [November 3, 2019, 4:23pm UTC](https://discourse.processing.org/t/ellipse-appears-at-0-0-due-to-an-array-i-want-it-to-only-appear-when-mouse-is-pressed/15198/2 "2019-11-03T16:23:24Z")

</div>

Some approaches:

- If the location of the node is not 0,0, draw the node.
- If the bit “mouseHasBeenPressedAtLeastOnce” is true, draw the node
- Populate the node with numbers outside the field of view (e.g. -1000,-1000), then update them to within the field of view after a mouse press.
- make an arraylist, rather than an array, and leave it empty at first. check if it is null before drawing.

There are many more ways, but any one of these approaches will work.
