Mathematics of the Spirograph