Skip to content

Instantly share code, notes, and snippets.

@EnesKaraosman
Created April 16, 2020 04:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EnesKaraosman/d5b84a267b2213a61176800be15a062e to your computer and use it in GitHub Desktop.
Save EnesKaraosman/d5b84a267b2213a61176800be15a062e to your computer and use it in GitHub Desktop.
Triangle Shape
struct Triangle: Shape {
func path(in rect: CGRect) -> Path {
var path = Path()
// Orta - Üst
let topCenter = CGPoint(x: rect.midX, y: rect.minY)
path.move(to: topCenter)
// Sol Kenar
path.addLine(to: .init(x: rect.minX, y: rect.maxY))
// Alt Kenar
path.addLine(to: .init(x: rect.maxX, y: rect.maxY))
// Sağ Kenar
path.addLine(to: topCenter)
return path.strokedPath(.init(lineWidth: 8, lineCap: .round, lineJoin: .round))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment