There's a open-source implementation, if you want to dig into code: https://github.com/projectM-visualizer/projectm/
Looks like the visualizations are implemented here: https://github.com/projectM-visualizer/projectm/tree/master/src/libprojectM/MilkdropPreset
Basically, though, it's maths and GPU shaders, a.k.a. more maths.