Generative Geometry
Hilbert Weave
A Hilbert space-filling curve draws itself as a glowing teal-to-violet ribbon with a leading spark, cycling through orders 2–5 and looping continuously.
canvasmedium complexitymoderate motionpointer
Open on the canvas to copy the code → Free account · 3 copies a day · membership goes unlimited
Worth keeping?
Votes steer what gets built next — sign in to cast one, free to read
When to use it
Generative art backgrounds, math/algorithm showcase sections, dark-themed hero panels needing ambient geometric motion.
When not to
Light backgrounds (hardcoded dark navy). Contexts where high segment-count draw loops at order 5 (1024 cells) may stress low-end CPUs.
Working with an AI agent
Every component ships agent-ready metadata. An example instruction for this one:
Change the hue sweep from teal-violet to amber-rose by setting the base hue to 30 and the sweep range to 120 (line: `const h=(168+f*150)%360` → `const h=(30+f*120)%360`). Theme: dark tokens live in :root, the light variant in :root[data-theme="light"]; ?theme=light or a {type:'forever:theme'} postMessage switches at runtime.
Safe to edit
- hue base and sweep range (168 + f*150)
- draw speed (SPEED = 0.018)
- hold duration before order advance (hold > 90)
- order range (2..5 in the order++ loop)
- ribbon width multiplier (cell * 0.30)
- theme tokens (:root dark defaults + [data-theme=light] overrides)
Keep intact
- DPR-aware canvas sizing and setTransform
- visibilitychange start/stop guards
- IIFE wrapper
- prefers-reduced-motion static render branch
- theme hook (?theme= bootstrap + forever:theme message listener + theme tokens)
Known limitations
- Per-segment draw loop scales as O(n²) cells — order 5 draws 1023 segments twice per frame (glow + core), may drop frames on slow hardware
- Background color hardcoded in CSS (#021016) — must edit both CSS and ctx.fillStyle to change
More Generative Geometry components
- Voronoi Shatter14 drifting sites partition the canvas into cool-blue Voronoi mosaic cells; moving the pointer nudges the nearest site toward the cursor.
- Auto-MazeDepth-first maze carves itself wall by wall on a dark grid with shifting hue; a bright dot marks the active cell. Resets with a new color on completion.
- Truchet Tiles8x8 grid of rainbow quarter-arc Truchet tiles that flip orientation in slow sine waves, weaving shifting interlocked curves across a dark background.
- SpirographA hypotrochoid spirograph traced progressively on canvas with a shifting hue; each cycle completes then resets with new random radii and color.
- L-System PlantAn L-system fractal plant grows branch by branch from the canvas bottom, swaying gently; clicking triggers a wobble and regrows a randomized plant.
- Rotating Mandala12-fold mandala of 5 nested polygon rings that counter-spin, breathe in scale, and cycle through lilac-gold hues. Tap adds a spin impulse.