Great discussion! You can also make this more efficient / higher performance in several ways.
First, 95% of your screen is always going to be black. Don’t compute distances and component weights on each black pixel in that huge area – just fill them black, then compute pixels only in the box around the mouse cursor.
Second, you could do this with a mask() – then all your weights are computed once, and you just repopulate the spotlight image (square) each frame, then apply the circular gradient mask and display. Two-pass, but flexible.
Here is a demo that takes the sketch from kll and computes the gradient only in a small box around the mouse cursor.
Next, if you want to change computing the distances and weights every frame into a pre-computed mask image, see: