This code is based on the original article by Andy Sloane, who first created the Donut Math in C. This piece of art is also featured in videos by Lex Fridman and Joma Tech.
The code is re-written in Python with heavy annotation to make it easier to understand. Feel free to change the variables at the top of the script to experiment with the effect of different parameters. There is no dependency on any external libraries. Just run the script (python donut.py
) and watch the magic happen.