White light is really all the colors mixed together. Glass bends each color by a different amount, violet the most and red the least, so a prism pulls them apart into a rainbow.
The source code is at github.com/KirillOsenkov/LiveGeometry. It is written in .NET and Avalonia.
Also here: Catriona Agg's geometry puzzles and puzzles from Geometry Snacks made interactive; the same gallery in plain JavaScript; and how to embed a live drawing in your own page.