A comet rounds the Sun and grows a straight blue ion tail and a curved dust tail.
The nucleus follows an exact Kepler orbit, and time runs slower near the Sun so perihelion gets the screen time. Sublimating ice lifts dust off the day side, and sunlight pushes each grain outward with a fraction beta of solar gravity, so every grain moves on its own Kepler orbit with an effective GM of 1 - beta and is integrated with leapfrog steps sized to its distance. The broad, curved yellow tail is just where forty thousand grains end up, each smeared into a short streak along its drift from the nucleus: small grains race outward, big ones barely leave the orbit. Ions are swept up by the solar wind, computed in closed form from their birth so the blue tail stays straight, aberrated and kinked by gusts. An overlay draws syndynes and synchrones from tracer grains, and an inset ray traces a rotating two-lobed nucleus venting jets from its sunlit side.
Try it. Drag the perihelion marker to change how close the comet passes and where; the arrow keys do the same. Press S (or click empty space) to show syndynes and synchrones, and Space to speed up. Left alone, each orbit gets a new perihelion.
Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.
Build a comet with a dust tail and an ion tail made from real particle physics, using 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:
- Use units where the Sun's GM is 1 and distances are in AU. Put the Sun at the center of a canvas that fills the window and give the comet an eccentric orbit, with perihelion about 0.4 AU and aphelion about 5 AU.
- Move the comet exactly along its orbit by solving Kepler's equation E - e sin E = M with a few Newton steps each frame.
- While the comet is within about 3 AU, release dust grains from it every frame, with the comet's velocity plus a small random kick toward the Sun. Give each grain a random beta between 0 and 1: sunlight cancels that fraction of the Sun's gravity, so the grain feels GM = 1 - beta.
- Step every grain with leapfrog, using smaller steps closer to the Sun, and draw them as faint warm yellow dots. A curved, fanned dust tail should appear on its own.
Once that works, make it beautiful:
- Add an ion tail: ions start at the comet and move straight away from the Sun at about 13 AU per time unit, fading quickly. Draw them in blue.
- Accumulate grains and ions into a low-resolution brightness buffer, blur it, and draw it additively over a starfield with a glowing Sun.
- Slow time down near the Sun and speed it up far away, and let the camera zoom to frame the comet and its tails.
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 drawing syndyne and synchrone lines, a draggable perihelion, or kinks that travel down the ion tail from gusts in the solar wind.