-
-
Save sturdysturge/e1cfce167ab3d9102f280608d5df6401 to your computer and use it in GitHub Desktop.
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
struct TopCornersMaskShape: Shape { | |
let radius: CGFloat | |
func path(in rect: CGRect) -> Path { | |
var path = Path() | |
let topLeftCorner = CGPoint(x: rect.minX + radius, y: rect.minY + radius) | |
let topRightCorner = CGPoint(x: rect.maxX - radius, y: rect.minY + radius) | |
let topLeftCornerStart = CGPoint(x: rect.minX, y: rect.minY + radius) | |
let topRightCornerStart = CGPoint(x: rect.maxX - radius, y: rect.minY) | |
let bottomRight = CGPoint(x: rect.maxX, y: rect.maxY) | |
let bottomLeft = CGPoint(x: rect.minX, y: rect.maxY) | |
path.move(to: topLeftCornerStart) | |
path.addRelativeArc(center: topLeftCorner, radius: radius, startAngle: .degrees(180), delta: .degrees(90)) | |
path.addLine(to: topRightCornerStart) | |
path.addRelativeArc(center: topRightCorner, radius: radius, startAngle: .degrees(270), delta: .degrees(90)) | |
path.addLine(to: bottomRight) | |
path.addLine(to: bottomLeft) | |
return path | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment