Visualizations
476 / 500

476 · Generative art

Celtic Knotwork

Manuscript knot panels woven from a grid of breaks. Click to reweave the threads.

The panel is a grid of cells with a crossing site at the midpoint of every cell edge, and the strands run diagonally from site to site, so a panel with no breaks is a plain plait. A break is a mirror on a site, lying along the edge or across it: a strand that meets one turns back instead of crossing, and the border is lined with breaks so every strand stays inside. Walking from site to site always closes into loops, so the knot is one or more threads, and each is traced and laid in its own pigment (mirror-image threads share one, and a single unbroken thread is gilded). The walk is smoothed with Bezier curves, over/under parity is propagated along every thread so the weave always alternates, and the holes between ribbons are found as faces of the planar graph and painted in two colors, by whether they hold cell centers or cell corners.

Try it. Click or tap a crossing to cycle it through a break along the edge, a break across it, and back to a crossing; with mirror symmetry on, the edit is reflected into all four quarters. R or Space draws a new design, C clears to a plain plait, and S toggles symmetry. Left alone, it keeps editing itself.

  • Grid and breaks (mirror curves)
  • Thread tracing
  • Alternating over/under weave
  • Planar face 2-coloring

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build a Celtic knotwork generator with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

Start simple:
- Make a canvas that fills the window, stays sharp on high-DPI screens (scale by devicePixelRatio), and resizes with the window. Paint a dark panel in the middle.
- Lay out a grid of square cells, about 10 by 6. Put a "site" at the midpoint of every cell edge. Edges on the outer border are always walls.
- Each site is either a crossing or a break. A strand moves diagonally from site to site, half a cell at a time. At a crossing it carries straight on. At a break lying along a horizontal edge it flips its vertical direction (and along a vertical edge its horizontal direction), like a ball bouncing off a wall.
- Starting from every unvisited site and direction, follow the strand until it comes back to where it started. That closed walk is one thread. Mark everything it visits.
- Draw each thread as a thick line through the sites it crosses, with a different color per thread. Click near a site to toggle a break there and redraw.

Once that works, make it beautiful:
- Smooth the path: pass straight through crossings and turn in a rounded curve just before each break, using Bezier curves.
- Draw the strands as ribbons: a dark outline, then the colored body, then a thin light highlight.
- Weave them: at every crossing, redraw a short piece of one strand on top. Alternate over and under as you walk along each thread.
- Add a gold frame and a parchment background, and place breaks symmetrically so designs look balanced.

Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as painting the holes between ribbons, diagonal breaks for pointed corners, or animating a light running along each thread.
PreviousDrift RacerPacejka tire physics on a generated circuit, with a drifting AI that plans ahead. NextAnt FarmA colony digs its nest grain by grain behind glass, with no plan but local rules.

Related visualizations

  • Girih Star PatternsGenerative art Interlaced Islamic star patterns built live from one angle over a hidden tiling.
  • String ArtType and image One black thread, thousands of straight chords, and a face appears on the loom.
  • Weaving LoomGenerative art A floor loom weaves shaded yarn cloth live from historical drafts you can edit.
  • KolamGenerative art A hand traces a rice-flour kolam: one unbroken line looping around every dot.
  • Knot Table3D Prime knots up to seven crossings, relaxed as tubes, with live Alexander polynomials.
  • Floral OrnamentGenerative art Scrolls, acanthus leaves and flowers grow to fill any frame, like an engraver's panel.
  • Differential GrowthGenerative art One closed line grows, buckles and folds into brain coral without ever crossing.
  • KnittingType and image Pixel art becomes Fair Isle knitting, stitch by twisted stitch, live on the needle.
  • KintsugiGenerative art A glazed tea bowl shatters along branching cracks, then is mended with flowing gold.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs