~/lab/donut.c — zsh
cd ..thomas@parkin ~/lab $ ./donut.c# the spinning ascii torus
drag to fling it
man donut

A torus drawn entirely in text, after Andy Sloane's famous donut.c (2006), whose C source is itself shaped like a donut. Read hisexplanation of the maths.

Each frame samples a few thousand points on the torus surface (two angles, θ around the tube and φ around the centre), rotates them about two axes, and projects them onto the character grid with a 1/z perspective divide. A z-buffer keeps the nearest point in each cell, and the dot product of the surface normal with a light direction picks a character from the ramp, dim to bright.