Sunlight goes into a drop of rain, bounces off the back of it and comes out again, heading back toward the sun. On the way in and on the way out it bends, and every color bends by its own amount, so the colors come out a little apart.
The source code is at github.com/KirillOsenkov/LiveGeometry. It is written in .NET and Avalonia.