Skip to content

Instantly share code, notes, and snippets.

@helloworldsmart
Last active November 30, 2016 08:23
Show Gist options
  • Select an option

  • Save helloworldsmart/deb40baee10fbb825b085bee9b9a7eb1 to your computer and use it in GitHub Desktop.

Select an option

Save helloworldsmart/deb40baee10fbb825b085bee9b9a7eb1 to your computer and use it in GitHub Desktop.
drawGeometry
enum Geometry: Int {
case triangle = 3
case square = 4
case pentagon = 5
case hexagon = 6
}
func drawGeometry(stepsLabel: Int, sides: Geometry) {
let count = sides.rawValue
let exteriorAngle = 360 / count
for _ in 0..<count {
move(steps: stepsLabel)
rotate(degrees: exteriorAngle)
}
}
func runDrawing() {
drawGeometry(stepsLabel: 50, sides: Geometry.triangle)
drawGeometry(stepsLabel: 50, sides: .pentagon)
drawGeometry(stepsLabel: 50, sides: .hexagon)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment