Travis Kirton


Creating a star is a lot like creating a circle, the only difference is that you also specify variables for its inner and outer radius.

let star = Star(center:, pointCount: 5, innerRadius: 10, outerRadius: 20)

Regular Polygons

Creating a regular-sided polygon is even easier… The major difference here is you specify the number of sides and the phase.

The phase is it initial rotation of the shape… You can specify a value (in radians) if you want the shape’s points to start in a different position.

//defaults to 5 sides and 0 phase
let hexagon = RegularPolygon(center:, radius: 90)
let pentagon = RegularPolygon(center:, radius: 90, sides: 5, phase: M_PI_4)


let dx = Vector(x: canvas.width/5, y: 0)
let star = Star(center:, pointCount: 20, innerRadius: 80, outerRadius: 100)
let hexagon = RegularPolygon(center: + dx, radius: 90, sides: 6, phase: 0)