Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : Cannot figure out why alpha is acting strange here!

$
0
0
GoToLoop, the second example given by lasko25 already tried your suggestion (which was my guess too...).
That said, indeed the pixels on the main graphics are opaque, but the rectangles drawn over them have transparency and should merge with these opaque pixels. Actually, they do that when they are over the HeatPoint.
I remember people reporting issues with transparency when its value is low, or something like that. They don't add up correctly.
With a white background, the issue is the same...
Mmm, it is not about low alpha values, if I map to 175,100 instead of 175,0, the issue remains. Looks like Processing keeps the alpha value somehow, and fails to merge two pixels with alpha.
Same issue in 1.5.1 and 2.0 (I write as I experiment...)

Ah, I see. The flaw is in the colorPixel() function. It takes distance from each heat point, but it keeps only the last one!
It wasn't a problem with drawing the transparent rectangles, but in finding their color.
Two solutions:
- As said, draw each heat point with its halo in a PGraphics. Advantage: higher speed, as the PGraphics will be 400x400 only, so that's less pixels to examine, and only one heat point to check (distance from center of the PGraphics). Probably the solution to use.
- With less impact on your code, do the math on colorPixel() to merge the results for each heat point.

Viewing all articles
Browse latest Browse all 1768

Trending Articles