Created
September 14, 2020 04:04
-
-
Save prafullakumar/c06c2cfcf0f2dca04ea736ab00c0a9af to your computer and use it in GitHub Desktop.
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 PieChartCell: Shape { | |
let startAngle: Angle | |
let endAngle: Angle | |
func path(in rect: CGRect) -> Path { | |
let center = CGPoint.init(x: (rect.origin.x + rect.width)/2, y: (rect.origin.y + rect.height)/2) | |
let radii = min(center.x, center.y) | |
let path = Path { p in | |
p.addArc(center: center, | |
radius: radii, | |
startAngle: startAngle, | |
endAngle: endAngle, | |
clockwise: true) | |
p.addLine(to: center) | |
} | |
return path | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment