Visualizations
365 / 500

365 · Math

Siteswap Juggler

Juggling notation made physical: true parabolas, a ladder diagram and the state graph.

A siteswap lists throw heights, one per beat with the hands alternating, and it is jugglable exactly when no two balls land on the same beat: the permutation test i + t_i mod p, after which the average theorem gives the ball count. The parser also reads multiplex throws like [43]14 and synchronous patterns like (4,2x)(2x,4), checking that every catch at every hand is matched by a throw. Each throw of height h is caught h minus the dwell time later, so the juggler's hands run a scoop and every ball follows the parabola that joins them under g = 9.81 m/s^2, with the camera zooming out (the 9 in 97531 really rises more than three meters) and long-exposure traces of the last few beats. Below, a ladder diagram runs ahead of the clock, and beside it the state graph (which of the next beats already have a ball due) shows the pattern as a cycle; switching between patterns with the same ball count follows the shortest path found by breadth-first search, drawn in red.

Try it. Pick a pattern from the ribbon, or type one (digits, a to z, [multiplex], (sync)) and press Enter; the parser explains why a pattern fails. Click any state in the graph to make the juggler detour through it and find the way back. Space or the arrow keys step through the ribbon.

  • Siteswap notation
  • State graphs
  • Breadth-first search
  • Projectile motion
  • Procedural character animation

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 siteswap juggling animator 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.
- A siteswap like 531 is a list of throw heights, one per beat, with the hands alternating. A throw of height h lands h beats later, so odd throws cross to the other hand and even throws come back to the same hand.
- Validate the pattern: the average of the throws must be a whole number (the number of balls), and (i + t_i) mod p must hit every beat exactly once. Show a clear message when it fails.
- Animate it: give each beat a duration (about 0.25 seconds) and a dwell time (about 0.6 beats). A ball thrown at beat t is caught at beat t + h - dwell, and in between it follows the parabola that joins the throwing and catching hand positions under real gravity (9.81 m/s^2, with a sensible pixels-per-meter scale).
- Move each hand in a small loop: catch on the outside, carry down and in, throw from the inside, return empty.
- Draw a simple figure with arms that reach the hands, and colored balls.

Once that works, make it rich:
- Add a text box to type a pattern, and buttons for famous ones: 3, 441, 531, 51, 423, 744, 97531.
- Draw a scrolling ladder diagram below the juggler: two rails for the hands and an arc for every throw.
- Zoom the view out for high throws so the arcs stay physically correct.

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 the state graph of patterns with shortest transitions between them, multiplex and synchronous notation, or long-exposure light trails.
PreviousRoguelike ExplorerAn amber-terminal dungeon crawl that explores itself, cat in tow, by rolling down a Dijkstra map. NextRebound RobotsRobots slide until they hit something. A* finds the fewest moves to the target.

Related visualizations

  • Dynamical BilliardsPhysics A fan of 1,000 balls in reshapable tables, linked live to the Birkhoff phase map.
  • Pool Trick ShotsGames Billiards with real spin physics and an AI that plans by simulating every shot.
  • Ball PitPhysics Hundreds of colorful balls tumble, stack and bounce off each other.
  • Marble LabyrinthGames A wooden tilt maze where a careful AI steers a steel ball between the holes.
  • Gridlock SolverAlgorithms Map every position of a sliding-car puzzle, solve it, and generate harder ones.
  • Hyperbolic MazeGames A labyrinth in negatively curved space: the world glides past while you stay at the center.
  • Vector BallsRetro 512 chrome spheres, depth sorted, morphing from a torus knot to DNA to a smiling face.
  • Catalan BijectionsMath One Catalan object drawn five ways at once, linked piece by piece as it morphs.
  • Point-Light WalkerIllusions Thirteen dots on black, and you see a person walking, running, dancing or carrying a box.

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

← More from Emergent Mind Labs