Skip to content

Instantly share code, notes, and snippets.

@EnesKaraosman
Last active April 16, 2020 03:54
Show Gist options
  • Save EnesKaraosman/8949e8c3ef0aab1c91e1e8e97468805d to your computer and use it in GitHub Desktop.
Save EnesKaraosman/8949e8c3ef0aab1c91e1e8e97468805d to your computer and use it in GitHub Desktop.
PacMan Custom Shape
extension CGRect {
var center: CGPoint {
return .init(x: self.midX, y: self.midY)
}
}
struct PacMan: Shape {
var endAngle: Angle
func path(in rect: CGRect) -> Path {
var path = Path()
path.move(to: rect.center) // 1
// 2
path.addArc(
center: rect.center,
radius: rect.midX, // Yarıçap uzunluğu
startAngle: .degrees(0),
endAngle: endAngle,
clockwise: false
)
// 3
path.closeSubpath()
return path
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment