Updated

ulam

A mouse-driven spiral of primes, evens and odds.

ulam: spiral arms of magenta, yellow and cyan dots on black

What it is

A full-screen animated spiral of 5,000 dots, each colored by whether its index is prime, even or odd. Moving the mouse reshapes it as you go: left and right for the angle between dots, up and down for the starting distance.

Despite the name, it is not the classic Ulam spiral, which lays integers out on a square grid. It is a live companion to spiral, with the same polar layout and colors, redrawn every frame.

How it works

  • Pts.js provides the full-window canvas and the animation loop.
  • Every frame, all 5,000 points are recomputed from the current mouse position.
  • Primes are magenta, even numbers yellow and odd numbers cyan.
  • The whole thing is a single HTML file.

Built with

  • Pts.js
  • Canvas
  • JavaScript

Started