A solar system in your browser. Tap or click to add a planet, drag to fling it. Turn on long exposure and every orbit stays in the picture, or go zen and let it fill the screen.
Your device asks for less motion, so the simulation is standing still. Feel free to start it yourself.
How it’s built
Every planet pulls on every other planet, sixty times a second, on a plain Canvas 2D. The trails live on a second canvas that never gets wiped completely.
- Softened gravity. A small extra distance (
softening) stops close passes from flinging planets into infinity. Between two planets it grows with their size, so a near miss nudges instead of slingshots. - A fixed timestep. Physics runs in steps of 1/60 s, at most four per frame, so a slow phone slows the system down instead of blowing it up.
- Light that adds up. Every step fades the trail canvas a little and draws new segments with
lighter, so crossing trails glow. Long exposure just fades slower. - Born in orbit. A tapped planet gets the speed for a circular orbit around the sun:
Math.sqrt(sun.mass / distance).