Last active
April 16, 2020 12:01
-
-
Save EnesKaraosman/190f308a9ef1f0a9d3b3aa0b2c0ce5d1 to your computer and use it in GitHub Desktop.
Balloon 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 Balon: Shape { | |
func path(in rect: CGRect) -> Path { | |
// Orta - Alt nokta | |
let bottomCenter = CGPoint(x: rect.midX, y: rect.maxY) | |
// Orta - Üst nokta | |
let upCenter = CGPoint(x: rect.midX, y: rect.minY) | |
var path = Path() | |
path.move(to: bottomCenter) // Başlangıç noktası | |
// Sağ Yarım kısım ) | |
path.addCurve( | |
to: upCenter, | |
control1: .init(x: rect.maxX, y: rect.midY), // Sağ - Orta | |
control2: .init(x: rect.maxX, y: rect.minY) // Sağ - Üst | |
) | |
// Sol Yarım kısım ( | |
path.addCurve( | |
to: bottomCenter, | |
control1: .init(x: rect.minX, y: rect.minY), // Sol - Üst | |
control2: .init(x: rect.minX, y: rect.midY) // Sol - Orta | |
) | |
return path | |
} | |
} | |
// Kullanım | |
Balon().frame(width: 160, height: 160) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment