Soft glow
A light in the middle of the canvas that fades out to the edge.
Write glow(x, y, size). It is called once for every pixel of a size by size canvas, x running right and y running down from 0 at the top left. Return a brightness from 0 to 1.
Measure from the pixel's centre, which is (x + 0.5, y + 0.5), to the canvas centre, (size / 2, size / 2). Call that distance d and let r = size / 2. Return 1 - d / r, but never less than 0, so the corners stay black.
Example: the pixel at (31, 31) on a 64 canvas has its centre at (31.5, 31.5), which is about 0.7071 from (32, 32). So glow(31, 31, 64) returns about 0.97790. Answers are checked to within 0.000000001.
Tests you can see
glow(31, 31, 64)0.9779029130879204glow(47, 31, 64)0.5153730493977868glow(0, 0, 64)0
More tests are hidden. The server runs them all before a time counts.
Run your code and this canvas paints itself.
Tab indents · Cmd/Ctrl+Enter runs