# Trails not fading completely WHY?

**URL:** <https://discourse.processing.org/t/trails-not-fading-completely-why/25514>\
**Category:** Beginners\
**Created:** [November 18, 2020, 3:26pm UTC](https://discourse.processing.org/t/trails-not-fading-completely-why/25514 "2020-11-18T15:26:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eyetoof](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@Eyetoof](https://discourse.processing.org/u/Eyetoof)\
**Post date:** [November 18, 2020, 3:26pm UTC](https://discourse.processing.org/t/trails-not-fading-completely-why/25514/1 "2020-11-18T15:26:41Z")

</div>

I learned a technique from the Ben Fry books for doing trails. Its very simple and effective but I have come across an issue that I don’t understand and wonder if someone can explain.

The technique is to, at the top of draw, draw a black filled rectangle with a low opacity (12 is what fry uses in examples).

Super simple code  
/void draw() {  
fill(0,0,0,12); // black low opacity fill, for trails.  
rect(0,0,width,height); // screen size rect over all the last draw pass work/

note: I am using HSB so thats why my fill has 3 values, 4 val is opacity. I had the same issues I describe below when using RGB.

In my code I have replaced the alpha value with a variable. I would like to be able to set it to zero so that it will just draw a twisty mess on the screen and then pull it to higher numbers and get a nice variation on the trails. They could be dynamically changing.

This works but I have found a curious thing. When my Alpha goes below 12. The screen never totally blacks out the screen.

Why? Even at 2 for alpha I would think it would eventually go completely black???. My patterns are a bit random so its not that the path gets retraced before it can build up.

I am making my variable an int, to make sure its not a rounding, error, though I don’t know why that would matter either…

Does the adding up of values stop short of full black for some reason? I would think it would just “go over” and give the effect I want. I have attached some screens below.

This is for a project that will be projected, so while it IS a very subtle thing, I am concerned that on a projector, its going to really show.

Besides… it makes no sense.!! :). I am sure its doing exactly what I am telling it too, and I just need to talk to it better, but how might I do that?

Screens attached, hope it makes sense title tells what the variable value is at time of capture.

Thank you!!

First here is the effect when alpha = 12. The original standard application of Frys approach.

 ![rect opat 12](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/3cc0129c6d5d0a6550c2703dd71f6aa06fb4a6bb.jpeg)

And here it is, alpha = 0. For graffiti like goodness.

 ![rect opt 0](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/2/2d4c85eab0da506552cc8a8d52d445a8ec5f3dab.jpeg)

But as I try to dial in the inbetween good ness and the REAaaaalllly longgggggg traaaaiiiiilzzzzz  
I get left over cruft…  
Alpha = 10:

 ![rectOpat10](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/dc9e21c890abc55ae222aab18b9f8267250309ad.jpeg)

alpha = 8:

 ![rect Opat 8](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/9b8d02cb108240d9181a47b01664d974c27e7d91.jpeg)

alpha = 6

 ![rectOpat6](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/1/1ac6c35600846be82b2c6840e89f20c067e2aac1.jpeg)

alpha = 4

 ![trail_Opacity 4](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/93c9e7cd77babc3d9012af8be4de9adba843d32c.jpeg)

alpha = 2

 ![rectOpat2](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/4/4adfebd6568320947717ef35bfec6274921a47ba.jpeg)

Toof

---

<div class="post-metadata">

**Author:** ![tony](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tony/32/949_2.png) [@tony](https://discourse.processing.org/u/tony)\
**Post date:** [November 18, 2020, 5:04pm UTC](https://discourse.processing.org/t/trails-not-fading-completely-why/25514/2 "2020-11-18T17:04:23Z")

</div>

Interesting question!

I don’t know why this happens (maybe it warrants a source-code dive?). Regardless, I get the gist so my suggestion would be to look into `BLENDMODE(SUBTRACT)`.

The default behaviour of the canvas is to simply replace old pixels with new ones; however, SUBTRACT mode subtracts the new pixel values from the old. So instead of painting over with transparency, you’re directly subtracting x amount every loop, towards black (0,0,0).

The start of your draw might look like:

```auto
BLENDMODE(SUBTRACT);
background(1,1,1); // subtract 1 from every pixel
BLENDMODE(BLEND); // or is it NORMAL I forget 

// Rest of the code below

```

It might make more sense to see an [example](https://www.openprocessing.org/sketch/566877).

Let me know if you have questions!

---

<div class="post-metadata">

**Author:** ![Eyetoof](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@Eyetoof](https://discourse.processing.org/u/Eyetoof)\
**Post date:** [November 18, 2020, 5:21pm UTC](https://discourse.processing.org/t/trails-not-fading-completely-why/25514/3 "2020-11-18T17:21:52Z")

</div>

Totally works !!! thank you!
