Skip to content

Instantly share code, notes, and snippets.

@prafullakumar
Created September 14, 2020 04:04
Show Gist options
  • Save prafullakumar/c06c2cfcf0f2dca04ea736ab00c0a9af to your computer and use it in GitHub Desktop.
Save prafullakumar/c06c2cfcf0f2dca04ea736ab00c0a9af to your computer and use it in GitHub Desktop.
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