Created
January 9, 2023 07:06
-
-
Save msnazarow/7caf9495c47b7d9cdc31626ea2fb22fc to your computer and use it in GitHub Desktop.
HalfCircle
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 characters
struct TopHalfCircle: Shape { | |
func path(in rect: CGRect) -> Path { | |
var path = Path() | |
path.addArc( | |
center: .zero, | |
radius: 1, | |
startAngle: .radians(.pi), | |
endAngle: .zero, | |
clockwise: false | |
) | |
let transform = CGAffineTransform.identity | |
.translatedBy(x: rect.origin.x + 0.5 * rect.size.width, y: rect.size.height) | |
.scaledBy(x: rect.width / 2, y: rect.height) | |
return path.applying(transform) | |
} | |
} | |
struct BottomHalfCircle: Shape { | |
func path(in rect: CGRect) -> Path { | |
var path = Path() | |
path.addArc( | |
center: .zero, | |
radius: 1, | |
startAngle: .zero, | |
endAngle: .radians(.pi), | |
clockwise: false | |
) | |
let transform = CGAffineTransform.identity | |
.translatedBy(x: rect.origin.x + 0.5 * rect.size.width, y: 0) | |
.scaledBy(x: rect.width / 2, y: rect.height) | |
return path.applying(transform) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment