I figured this out while trying to grok how a circle is drawn. After smashing my face into my monitor for a couple months, it occured to me that virtually every equilateral shape is a circle with less sides. Imagine trying to draw a circle when all you have is three sticks… you get a triangle. The same thing with four sticks results in a square.

The end result was the above function: pass the number of sides (3 for triange, 4 for square, 8 for an octagon, etc… up to 360 for a circle), and a size, and you”ll get back a perfect polygon. Notice the lack of switch statements or if/else logic; the function attempts to draw a circle with as many passes as are defined in the size argument, so the natural product is the shape produced.