# Random ellipses fading in

**URL:** <https://discourse.processing.org/t/random-ellipses-fading-in/14748>\
**Category:** Coding Questions\
**Created:** [October 16, 2019, 4:13pm UTC](https://discourse.processing.org/t/random-ellipses-fading-in/14748 "2019-10-16T16:13:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mellebond](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mellebond/32/5177_2.png) [@mellebond](https://discourse.processing.org/u/mellebond)\
**Post date:** [October 16, 2019, 4:13pm UTC](https://discourse.processing.org/t/random-ellipses-fading-in/14748/1 "2019-10-16T16:13:54Z")

</div>

Hi!

I’m having troubel combining two codes. I’d like to have ellipses fade in and then dissappear again.  
Thanks in advance!

Code 1; (does the job OK but fades out.

```auto
void setup() {
  size(1920,1080);
  //size(3840,2160);
  frameRate(25);
  background(0);
  noStroke();
}

void draw(){
  fill(0,10);
  rect(0,0, width, height);
  fill(255);
  ellipse(random(width), random(height),4,4);
}

```

Code 2 (when I try more than one ellipse it doesn’t fade anymore)

```auto
void setup(){
  size(1920,1080);
  //(3840,2160);
  background(0);
frameRate(25);
  noStroke();

}
 
void draw(){
background(0); 
  fill(255,0+map(millis()%3000,0,3000,0,300));
 //ellipse(random(width), random(height),4,4);
ellipse(width/2,height/2,4,4);
}

```

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [October 16, 2019, 7:12pm UTC](https://discourse.processing.org/t/random-ellipses-fading-in/14748/2 "2019-10-16T19:12:08Z")

</div>

Hi. You can edit and format your code by selecting the text and tapping \</\>  
I think the problem with your second code is because you are using background(0) which does not fade like

```auto
  fill(0,10);
  rect(0,0,width,height);

```

---

<div class="post-metadata">

**Author:** ![Waboqueox](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/waboqueox/32/5643_2.png) [@Waboqueox](https://discourse.processing.org/u/Waboqueox)\
**Post date:** [October 17, 2019, 7:56am UTC](https://discourse.processing.org/t/random-ellipses-fading-in/14748/3 "2019-10-17T07:56:58Z")

</div>

> [@mellebond](#):
>
> combining two codes

Mmmm **I’m not sure about what you want**

fill(); affects to all the following lanes of your code till you change it to other configuration, just add more ellipses and they will act all in same mode:

```auto
void draw(){
  background(0);
  fill(255,0+map(millis()%3000,0,3000,0,300));
  for(int i=0;i < width; i+=50){
    for(int j=0;j < height; j+=50){
       ellipse(i, j,40,40);
    }
  }
}

```

In the first example the fade out happens because you are adding more transparent black layers and when you add transparent layers over and over, your layer will get to that color, hiding the ellipses drawn.

---

<div class="post-metadata">

**Author:** ![mellebond](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mellebond/32/5177_2.png) [@mellebond](https://discourse.processing.org/u/mellebond)\
**Post date:** [October 17, 2019, 1:06pm UTC](https://discourse.processing.org/t/random-ellipses-fading-in/14748/4 "2019-10-17T13:06:46Z")

</div>

I wanted the first code. But then reversed. So I exported it as a video and literally reversed it.  
Thanks anyway!
