# Trails not fading completely WHY?

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.

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

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

alpha = 8:

alpha = 6

alpha = 4

alpha = 2

Toof

1 Like

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:

``````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.

Let me know if you have questions!

3 Likes

Totally works !!! thank you!

1 Like