pattern_maker
payton@pschwarz$ ls pattern_maker/patterns/egg/
axial_flow.js fibonacci_dream.js oil_slick.js
cosmic_bloom.js gyroid.js oil_slick_sunset.js
cube_fire.js hc_pat.js orbital_cloud.js
3d_roto.js lava_lamp.js perlin_kal.js
fibonacci_bloom.js pulsars.js slicer.js
fibonacci_bloom_plain.js warp_core.js
fibonacci_bloom_rotate.js
Since pb_emu I’ve been building out a companion repo, pattern_maker, a pattern authoring system for a specific piece of hardware: a 3D-mapped egg sculpture with ~1400 individually addressable LEDs. The interesting constraint is that the mapping is actually 3D, not a 2D projection. So patterns that only use x and y look like wallpaper; the whole point is writing things that couldn’t exist on a strip or a panel.
The authoring loop
Three pieces:
AGENTS.md: a system prompt that turns Claude into a Pixelblaze pattern author. It knows the language is a JS subset with 16.16 fixed-point math (±32,768 range, precision 1/65,536), the render pipeline (beforeRender→render3D/render2D/render), the full built-in library, and (most importantly) the hard rules that will brick a Pixelblaze if broken: noarray()allocation inside render (leak, then crash), no nested functions (broken scope), notime()in render (only inbeforeRender), no infinite loops (there’s no watchdog). The rules aren’t theoretical; they came out of actual incidents.validate.py: a static analyzer that checks patterns against the actual Pixelblaze language rules (noarray()in render, notime()in render, no nested functions, requiredbeforeRender+render*exports, and so on), plus warnings for expensive ops in the hot path. Point it at a file or directory, non-zero exit on error, drops cleanly into a pre-deploy check. About 150 lines, and has saved me several redeploys.- pb_emu: the feedback loop. Edit a pattern on disk, the emulator reloads in ~700ms, runs it against the egg’s real LED map, shows the result live. No hardware in the loop until the very end.
Nineteen patterns in the collection so far, written this way without a single device reset. Six standouts below.
gyroid
An animated triply-periodic minimal surface. The implicit equation is compact enough to fit on a napkin:
sin(x) cos(y) + sin(y) cos(z) + sin(z) cos(x) = 0
Each LED evaluates the equation at its own position (scaled and drifting with time) and lights based on how close to zero the result is. On a 2D projection this would just be wiggles; on the 3D egg you can see the actual flowing bands of the surface. Proof-of-mapping pattern that also happens to be beautiful.
pulsars
Two bright point sources orbit through the interior of the egg on incommensurate 3D Lissajous paths. Each source lights nearby LEDs with an inverse-quadratic core glow and emits expanding spherical shells that propagate outward through the volume. You can follow each source with your eye as a moving bright spot, and watch shells wash across the far side of the egg with correct time delay. Hardest to fake without real 3D positions, so it’s the demo pattern I hand people first.
fibonacci_bloom
8 clockwise and 13 counter-clockwise spirals laid out at the golden angle (137.507°). Every structural and temporal constant derives from φ, the Fibonacci sequence, or the golden angle itself: spiral slopes are (k·GA mod 2π) / k, bloom and rotation periods are golden-ratio multiples of each other, so nothing ever re-syncs. The visual is what the math produces, nothing is hand-tuned.
oil_slick
Two perlin noise fields per pixel: a low-frequency flow field that warps the sample coords (domain warping, which gives you smeared, streaky flow instead of isotropic blobs), and a higher-frequency thickness field sampled at the warped coords, which indexes into a sunset palette. Reads as the optical-path-length color shift of a thin oil film. Brightness stays high on purpose, since real oil slicks are luminous, not dim.
orbital_cloud
Treats the egg’s surface as a sphere and renders the squared modulus of a real-spherical-harmonic field:
Ψ(θ, φ) = Σᵢ cᵢ · Y_{lᵢ}^{mᵢ}(θ, φ)
The coefficient vector slowly crossfades between hand-tuned orbital recipes (s, p_z, p_x, d_z², d_{x²−y²}, f_z³, and hybrids), so the LEDs trace lobes that morph between recognizable atomic-orbital shapes via unfamiliar in-between superpositions. Also precesses slowly around the vertical axis, with a separate Fibonacci-period palette rotation on top. The math is a homework problem; the egg-scale rendering is just showing off.
lava_lamp
3D metaballs. A handful of blob centers drift through the volume with a strong upward bias; each pixel sums an inverse-square contribution from every blob, smoothsteps the sum into an “inside-ness” in [0, 1], and drives palette + brightness from that. Globs merge and split with the right edge softness, the palette spans violet to hot yellow through a black transition, and each blob carries its own palette offset so some globs read cool-red and others hot-yellow. Instantly recognizable as a lava lamp from across the room.
The rest
The other thirteen: a few kaleidoscopes (cosmic_bloom, perlin_kal, hc_pat) that do N-fold folds around a selectable axis; two more 3D showcases (slicer, a tumbling plane with a bright intersection ring, and warp_core, concentric rings rushing past a wandering axis with psychedelic palette rotation); cube_fire, a multiplying-sines grid of pulsing spheres; axial_flow with a traveling ring on a tumbling axis; variants and experiments (fibonacci_bloom_plain, fibonacci_bloom_rotate, fibonacci_dream, oil_slick_sunset); and 3d_roto, which demonstrates pattern-space rotation via matrix transform and degrades gracefully down to 1D.
Capturing the videos above was itself an exercise in automation: a Puppeteer script boots pb_emu headlessly, loads each pattern against the real egg map, and records the canvas via MediaRecorder for a few seconds. Re-runnable on every pattern change. That script lives in the repo next to the patterns.
payton@pschwarz$ █