# Trail effect on waterfall issue

**URL:** <https://discourse.processing.org/t/trail-effect-on-waterfall-issue/7440>\
**Category:** Coding Questions\
**Created:** [January 12, 2019, 3:11pm UTC](https://discourse.processing.org/t/trail-effect-on-waterfall-issue/7440 "2019-01-12T15:11:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bertin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/bertin/32/391_2.png) [@bertin](https://discourse.processing.org/u/bertin)\
**Post date:** [January 12, 2019, 3:11pm UTC](https://discourse.processing.org/t/trail-effect-on-waterfall-issue/7440/1 "2019-01-12T15:11:41Z")

</div>

Hi all! I’m trying to implement a simple waterfall sketch, but I’m having an issue with how to show a trail effect on my drops object while moving acros the screen. Here is my code:

```auto
import java.util.List;
import java.util.Iterator;

int DROPS_PER_FRAME = 10;
float DROP_RADIUS = 5;
float GRAVITY = 1;
float FRICTION = 0.1;
float X_OSCILLATION = 1;
float EXP_RADIUS = 250;
float EXP_POWER = 100;
float WIND_FRICTION = 0.005;
float WIND_MARGIN_LIMIT = 0.25;

List<Drop> drops;
float xWind;

void setup () {
  fullScreen();
  drops = new ArrayList<Drop>();
  xWind = width/2;
}

void draw () {
  background(0, 0, 0, 100);
  rain();
  drops();  
}

void rain () {
  
  for(int i=0; i < DROPS_PER_FRAME; i++)
    drops.add(new Drop(random(-2*width, 4*width), 0));
  
  Iterator<Drop> d = drops.iterator();
  while(d.hasNext()) {
    if(d.next().isOffscreen())
      d.remove();
  }
}

void drops () {
  for(Drop d : drops) {
    d.move();
    d.show();
  }
}

////////

class Drop {
  
  float x, y;
  float xSpeed, ySpeed;
  int R,G,B;
  
  Drop(float x, float y) {
    
    this.x = x;
    this.y = y;
    this.xSpeed = 0;
    this.ySpeed = 0;
    this.R = int(random(50));
    this.G = int(random(255));
    this.B = 255;
    
  }
  
  void show () {
    noStroke();
    fill(this.R, this.G, this.B);
    ellipse(this.x, this.y, DROP_RADIUS*2, DROP_RADIUS*2);  
  }
  
  void move () {
    
    this.xSpeed += random(-X_OSCILLATION, X_OSCILLATION);
    this.ySpeed += GRAVITY;  
    
    this.x += this.xSpeed * FRICTION;
    this.y += this.ySpeed * FRICTION;
    
  }
  
  boolean isOffscreen () {
    return this.y - DROP_RADIUS > height; 
  }
  
  
}

```

I put a bit of alpha in the backgound funcion `background(0, 0, 0, 100)`, what I expected to happen was that every frame is adding a layer of black on the screen, and with the drops keep moving I was expecting a trail effect of every drop that disappear after a bit, but nothing is happening.  
What have I done wrong?

Thank you!

---

<div class="post-metadata">

**Author:** ![Architector\_4](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/architector_4/32/813_2.png) [@Architector\_4](https://discourse.processing.org/u/Architector_4)\
**Post date:** [January 12, 2019, 3:41pm UTC](https://discourse.processing.org/t/trail-effect-on-waterfall-issue/7440/2 "2019-01-12T15:41:56Z")

</div>

Hmm. That’s weird, it should do the trailing thing but it doesn’t.  
However, replacing `background(0, 0, 0, 100);` with `fill(0, 100); rect(0,0,width,height);` - which should do exactly the same thing - does a different thing, and does exactly what you want. So, you might want to use that instead.

Also it has a performance impact, too. I suggest using `fullScreen(P2D);` instead, as that’s usually faster.
