Created
June 16, 2020 15:34
-
-
Save prafullakumar/9da1ddec19a7437e1ec707bcca1175ee to your computer and use it in GitHub Desktop.
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
import SwiftUI | |
struct Heart: Shape { | |
func path(in rect: CGRect) -> Path { | |
let (x, y, width, height) = rect.centeredSquare.flatten() | |
let lowerPoint = CGPoint(x: x + width / 2, y: (y + height )) | |
let path = Path { p in | |
p.move(to: lowerPoint) | |
p.addCurve(to: CGPoint(x: x, y: (y + (height / 4))), | |
control1: CGPoint(x: (x + (width / 2)), y: (y + (height * 3 / 4))), | |
control2: CGPoint(x: x, y: (y + (height / 2)))) | |
p.addArc(center: CGPoint(x: (x + (width / 4)), y: (y + (height / 4))), | |
radius: (width / 4), | |
startAngle: .A180, | |
endAngle: .zero, | |
clockwise: false) | |
p.addArc(center: CGPoint(x: (x + (width * 3 / 4)), y: (y + (height / 4))), | |
radius: (width / 4), | |
startAngle: .A180, | |
endAngle: .zero, | |
clockwise: false) | |
p.addCurve(to: lowerPoint, | |
control1: CGPoint(x: (x + width), y: (y + (height / 2))), | |
control2: CGPoint(x: (x + (width / 2)), y: (y + (height * 3 / 4)))) | |
} | |
return path | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment