Created
May 27, 2018 01:47
-
-
Save veeneck/ecd0790dbfbfeafdf3d2c6d9b6090b2c to your computer and use it in GitHub Desktop.
Revisions
-
Ryan Campbell created this gist
May 27, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ let radius: CGFloat = 150 / 2.0 let bezierPath = CGMutablePath() let centerPoint = CGPoint(x: 0, y: 0) var thisPoint = CGPoint(x: radius, y: 0) bezierPath.move(to: centerPoint) var thisAngle: CGFloat = 90 let unitCount: CGFloat = count let spacingDegrees: CGFloat = 6.0 let sliceDegrees: CGFloat = 360.0 / unitCount - spacingDegrees for _ in 0..<Int(unitCount) { let x = radius * CGFloat(cosf(Float((thisAngle).degreesToRadians()))) + centerPoint.x let y = radius * CGFloat(sinf(Float((thisAngle).degreesToRadians()))) + centerPoint.y thisPoint = CGPoint(x: x, y: y) bezierPath.addLine(to: thisPoint) thisAngle += sliceDegrees let x2 = radius * CGFloat(cosf(Float((thisAngle).degreesToRadians()))) + centerPoint.x let y2 = radius * CGFloat(sinf(Float((thisAngle).degreesToRadians()))) + centerPoint.y thisPoint = CGPoint(x: x2, y: y2) bezierPath.addLine(to: thisPoint) bezierPath.addLine(to: centerPoint) thisAngle += spacingDegrees }