Last active
April 16, 2020 03:54
-
-
Save EnesKaraosman/8949e8c3ef0aab1c91e1e8e97468805d to your computer and use it in GitHub Desktop.
PacMan Custom Shape
This file contains 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 characters
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