I’ve been playing around a bit with Processing.org – a kinda-graphical programming language. One of the effect that I wanted to play with was a kind of radial transparency – a blob of colour that faded out toward the edges. After playing around for a while with drawing multiple ellipses, I settled on a pixel-based subroutine.
We create a new
PGraphics object to hold the blob, then for each pixel calculate the distance from the centre as a proportion of the radius using the handy
Math.hypot() method. Then, to get nice smooth fade-outs near the edges, we invert it ...