Grayson’s Bicolor Orb
Half blue. Half amber. One face. One function: map().
A scan-line gradient rendered with the circle equation — no gradient fill, just math.
Color as Code, Code as Color
Grayson built a face-like bicolor orb entirely from p5.js drawing primitives.
The upper half transitions from deep blue to cyan; the lower half from amber to yellow.
Two ring-shaped eyes and a vivid red smile complete the face. The color gradient is not
a background image or a CSS trick — it is computed mathematically, one horizontal
scan line at a time, using the circle equation and p5’s map() function.
Unlike Ethan’s animated emoji, this sketch calls noLoop() in
setup(). The entire image is computed in a single pass through
draw() and then the sketch stops. This is not a limitation; it is an
architectural choice. Every pixel placement is deliberate, calculated, and permanent.
map() for linear interpolation of hue •
colorMode(HSB) already in use •
Scan-line rasterization (horizontal line() calls) •
Circle equation x = h ± √(r² − (y−k)²) •
noLoop() for single-frame computation •
Concentric circle() calls for ring-shaped eyes
map() lesson this sketch teaches:
map(y, 0, height, 240, 180) asks: “What fraction of the way
is y between 0 and height? Apply that same fraction to the
range [240, 180].” At the top of the canvas (y = 0),
hue is 240 (blue). At the midpoint, hue is 210 (cyan-blue). The color changes
continuously with every pixel row — not in steps, not at breakpoints.
One function call, infinite intermediate values. That is what map()
is for. See the S.P.A.R.K. Chat Log for the full tutorial.
Live Render — Single Frame
Computed once in draw() — noLoop() stops the loop immediately.
Every scan line is a separate stroke() + line() call.