Skip to content

Instantly share code, notes, and snippets.

@prafullakumar
Created June 16, 2020 15:53
Show Gist options
  • Save prafullakumar/2f799ed99fb44a648e43174337363c26 to your computer and use it in GitHub Desktop.
Save prafullakumar/2f799ed99fb44a648e43174337363c26 to your computer and use it in GitHub Desktop.
import SwiftUI
struct Club: Shape {
func path(in rect: CGRect) -> Path {
let (x, y, width, height) = rect.centeredSquare.flatten()
let center = rect.centeredSquare.center
let center1 = CGPoint(x: x + width / 2, y: (y + height/4 ))
let center2 = CGPoint(x: x + width / 4, y: (y + height/2 ))
let center3 = CGPoint(x: x + width * 3 / 4, y: (y + height/2 ) )
let radius = (width / 4)
let path = Path { p in
p.move(to: center)
p.addArc(center: center1,
radius: radius,
startAngle: .A360,
endAngle: .zero,
clockwise: true)
p.addArc(center: center2,
radius: radius,
startAngle: .A360,
endAngle: .zero,
clockwise: true)
p.addArc(center: center3,
radius: radius,
startAngle: .A360,
endAngle: .zero,
clockwise: true)
p.move(to: center)
p.addLine(to: CGPoint(x: x + width / 4, y: y + height))
p.addLine(to: CGPoint(x: x + width * 3 / 4, y: y + height))
p.addLine(to: center)
}
return path
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment