Visualizations
058 / 500

058 · Generative art

Harmonograph

A Victorian pendulum machine inks decaying roses and stars onto cream paper.

Two pendulums under a gimbal swing a long brass arm whose tip holds the pen, while a third, rotary pendulum carries the paper platform round in slow ellipses. Each is a real damped nonlinear pendulum integrated 1,200 times a second, so the pen traces Lissajous and rose figures that spiral inward as friction drains them, and because a pendulum slows slightly at large swings, the figure keeps precessing as it dies. Frequencies at small integer ratios with a fraction of a percent of detune give the delicate pinwheels and stars. The ink is laid onto a 1,400 pixel sheet with width that follows the pen's speed, a faint wider pass for bleed and a pen that slowly runs dry, and every finished drawing is pinned to the plate strip.

Try it. Drag across the sheet to push the pen pendulums and bend the drawing. Use the buttons (or N, number keys 1 to 9, P, I and Space) for a new drawing, a new ratio, paper, ink, speed and lifting the pen, and click a plate to look at it up close.

  • Damped nonlinear pendulums
  • Lissajous and rose curves
  • Speed-dependent ink width
  • Persistent offscreen ink layer

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 harmonograph, the Victorian pendulum drawing machine, 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 paint a cream sheet of paper in the middle.
- Model four damped pendulums as angles with velocities: two move the pen (x and y) and two move the paper (x and y). Each follows theta'' = -w^2 * sin(theta) - c * theta', stepped with semi-implicit Euler about 1,000 times per simulated second.
- The pen's position on the paper is the pen displacement minus the paper displacement, where each displacement is sin(theta) times a scale.
- Give the two pen pendulums the same frequency, a quarter cycle apart, so the pen goes round in circles, and give the paper pendulums a small integer multiple of that frequency (try 2 : 3), rotating the other way. Detune one frequency by about half a percent.
- Draw the pen's path onto an offscreen canvas that you never clear, in thin dark ink, a few hundred steps per frame, and draw that canvas onto the paper each frame. Stop when the pendulums have lost most of their energy.

Once that works, make it beautiful:
- Vary the line width with the pen's speed so the ink pools where the pen slows to turn, and draw a faint wider pass under each stroke so it looks like it soaked into the paper.
- Draw the machine: the paper moving on its platform, and a brass arm reaching from a pivot to the pen.
- Let the mouse push the pendulums: dragging across the paper adds the pointer's velocity to the pen pendulums.

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 a gallery of finished drawings, choosing ratios from a menu, or exporting the drawing as an SVG for a pen plotter.
PreviousGear Train WorkshopA blueprint bench where involute gears snap into mesh, drive clocks and jam. NextMCTS BloomFour-in-a-row against Monte Carlo Tree Search, its search tree blooming as a flower.

Related visualizations

  • Paper MarblingGenerative art Ink drops, combs and styluses on a size bath, then a print pulled onto paper.
  • Rose EngineGenerative art A simulated rose engine lathe cuts banknote-fine guilloche, one pass at a time.
  • Foucault PendulumPhysics A museum pendulum ploughs a rosette into sand as the Earth turns beneath it.
  • Pen PlotterGenerative art A SCARA plotter arm inks hatched, hidden-line drawings along a 2-opt optimized route.
  • Magnetic PendulumFractals A pendulum over three magnets, and the fractal map of where every release point ends up.
  • Double PendulumPhysics Pendulums that start almost identical and end up worlds apart.
  • Sumi-e BrushGenerative art A bristle-by-bristle ink brush paints bamboo on rice paper that wicks and bleeds.
  • Plotter LandscapeGenerative art A mountain range inked stroke by stroke, with exact floating-horizon hidden lines.
  • Broad-Nib CalligraphyType and image A dip pen writes italic and uncial letters; thick and thin come from the nib angle.

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

← More from Emergent Mind Labs