Created
April 16, 2020 04:12
-
-
Save EnesKaraosman/d5b84a267b2213a61176800be15a062e to your computer and use it in GitHub Desktop.
Triangle Shape
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 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