Skip to content

Instantly share code, notes, and snippets.

@Arrlindii
Created December 6, 2019 22:16
Show Gist options
  • Select an option

  • Save Arrlindii/c16a11da7abb7316347004738141b19c to your computer and use it in GitHub Desktop.

Select an option

Save Arrlindii/c16a11da7abb7316347004738141b19c to your computer and use it in GitHub Desktop.
func getPetalCenteres() -> [CGPoint] {
let h = radius
let center = CGPoint(x: h/2, y: h/2)
var points: [CGPoint] = []
let d = petalCount - Double(Int(petalCount)) > 0 ? 1 : 0
for i in 0..<Int(petalCount) + d {
let angle = (Double(i) + Double(self.scale)) * (360/Double(petalCount))
let angleInRad = angle*Double.pi/180
let point = CGPoint(x: center.x + CGFloat(cos(angleInRad) * h), y: center.y + CGFloat(sin(angleInRad)*h))
points.append(point)
}
return points
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment