Visualizations
198 / 500

198 · Generative art

Girih Star Patterns

Interlaced Islamic star patterns built live from one angle over a hidden tiling.

A hidden tiling of polygons is laid down first: one of the eleven Archimedean tilings, or a Laves dual made of kites, rhombs, pentagons or triangles. E. H. Hankin's polygons-in-contact method then launches two rays from the midpoint of every edge at the contact angle, and each ray runs until it meets its partner from the neighboring edge. Because both polygons on an edge use the same angle, the rays line up across it and chain into long straps. Every crossing is found, straps are traced as polylines, and over/under is propagated along each strap so the weave always alternates. The straps also form a planar graph whose faces are walked edge by edge and glazed like zellige, with congruent faces (same area and perimeter) sharing a color.

Try it. Drag left or right anywhere, or use the slider, to sweep the contact angle. The arrows and the tiling name step through 16 tilings, Construction (or a tap, or C) reveals the tiling and rays, and hovering lights up one whole strap. Arrow keys nudge the angle (hold Shift for fine steps) and Up/Down change the tiling.

  • Hankin polygons-in-contact
  • Archimedean and Laves tilings
  • Alternating over/under weave
  • Planar face traversal

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 an Islamic star pattern generator with JavaScript and the HTML canvas element, using Hankin's "polygons in contact" method. 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 it a deep blue background.
- Lay out a square grid of squares, each about 80 pixels across, covering the screen. Keep each polygon as a list of its corner points.
- For every edge of every polygon, find its midpoint and launch two rays into the polygon at a "contact angle" measured from the edge: one leaning toward each end of the edge.
- In each polygon, intersect the ray that leans toward a corner with the ray from the next edge that leans toward the same corner. Draw both rays from their midpoints to that intersection point.
- Add a slider for the contact angle (about 20 to 85 degrees) and redraw whenever it moves. Watch the stars appear.

Once that works, make it beautiful:
- Add the 4.8.8 tiling (octagons and squares) and switch between tilings with a key. Write each polygon as a center, a number of sides and a rotation, repeated on a lattice.
- Draw the lines as gold straps: a thick dark stroke, then a thinner gold stroke, then a thin pale highlight down the middle.
- Weave them: find every crossing, and redraw a short piece of one strap on top so it passes over the other. Alternate over and under as you walk along each strap.
- Fill the shapes between straps with glazed tile colors like lapis, turquoise and ivory.

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 more tilings like 3.12.12 or 4.6.12, coloring the regions automatically by finding the faces of the line pattern, or animating the angle through famous historical designs.
PreviousEarth-Rotation SynthesisRadio dishes ride the turning Earth to image a hidden galaxy, then CLEAN it. NextMurmurationThousands of starlings flock in 3D and scatter from a falcon.

Related visualizations

  • Celtic KnotworkGenerative art Manuscript knot panels woven from a grid of breaks. Click to reweave the threads.
  • Penrose PentagridMath Five grids of parallel lines dualize into a living Penrose tiling of stained glass.
  • Tessellation MorphMath Drag one edge of an Escher-style creature and every copy reshapes while still tiling.
  • Hyperbolic TilingMath An endless koi garden of {p,q} ponds tiling the Poincare disk, with fish circling.
  • Wallpaper GroupsGenerative art Paint once and any of the 17 plane symmetry groups repeats the stroke across the plane.
  • Einstein Hat TilingMath The 2023 aperiodic monotile, grown from its metatiles and morphed toward the spectre.
  • Tutte EmbeddingAlgorithms A hopeless tangle of edges relaxes into a crossing-free drawing, as Tutte proved it must.
  • Roman MosaicGenerative art Thousands of tesserae laid in rows that follow every outline, as a Roman mosaicist would.
  • Wythoff Kaleidoscope3D One draggable seed in a mirror triangle generates every convex uniform polyhedron.

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

← More from Emergent Mind Labs