added chatbubbleshape
This commit is contained in:
1 parent
b37c71720b
commit
2d29f82647
6 files changed
+124
-88
No files matched your search
@@ -0,0 +1,86 @@
|
||||
import SwiftUI
|
||||
|
||||
struct ChatBubbleShape: Shape {
|
||||
let isOutgoing: Bool
|
||||
func path(in rect: CGRect) -> Path {
|
||||
let width = rect.width
|
||||
let height = rect.height
|
||||
var p = Path()
|
||||
if isOutgoing {
|
||||
p.move(to: CGPoint(x: 25, y: height))
|
||||
p.addLine(to: CGPoint(x: 20, y: height))
|
||||
p.addCurve(
|
||||
to: CGPoint(x: 0, y: height - 20),
|
||||
control1: CGPoint(x: 8, y: height),
|
||||
control2: CGPoint(x: 0, y: height - 8)
|
||||
)
|
||||
p.addLine(to: CGPoint(x: 0, y: 20))
|
||||
p.addCurve(
|
||||
to: CGPoint(x: 20, y: 0),
|
||||
control1: CGPoint(x: 0, y: 8),
|
||||
control2: CGPoint(x: 8, y: 0)
|
||||
)
|
||||
p.addLine(to: CGPoint(x: width - 21, y: 0))
|
||||
p.addCurve(
|
||||
to: CGPoint(x: width - 4, y: 20),
|
||||
control1: CGPoint(x: width - 12, y: 0),
|
||||
control2: CGPoint(x: width - 4, y: 8)
|
||||
)
|
||||
p.addLine(to: CGPoint(x: width - 4, y: height - 11))
|
||||
p.addCurve(
|
||||
to: CGPoint(x: width, y: height),
|
||||
control1: CGPoint(x: width - 4, y: height - 1),
|
||||
control2: CGPoint(x: width, y: height)
|
||||
)
|
||||
p.addLine(to: CGPoint(x: width + 0.05, y: height - 0.01))
|
||||
p.addCurve(
|
||||
to: CGPoint(x: width - 11, y: height - 4),
|
||||
control1: CGPoint(x: width - 4, y: height + 0.5),
|
||||
control2: CGPoint(x: width - 8, y: height - 1)
|
||||
)
|
||||
p.addCurve(
|
||||
to: CGPoint(x: width - 25, y: height),
|
||||
control1: CGPoint(x: width - 16, y: height),
|
||||
control2: CGPoint(x: width - 20, y: height)
|
||||
)
|
||||
} else {
|
||||
p.move(to: CGPoint(x: 25, y: height))
|
||||
p.addLine(to: CGPoint(x: width - 20, y: height))
|
||||
p.addCurve(
|
||||
to: CGPoint(x: width, y: height - 20),
|
||||
control1: CGPoint(x: width - 8, y: height),
|
||||
control2: CGPoint(x: width, y: height - 8)
|
||||
)
|
||||
p.addLine(to: CGPoint(x: width, y: 20))
|
||||
p.addCurve(
|
||||
to: CGPoint(x: width - 20, y: 0),
|
||||
control1: CGPoint(x: width, y: 8),
|
||||
control2: CGPoint(x: width - 8, y: 0)
|
||||
)
|
||||
p.addLine(to: CGPoint(x: 21, y: 0))
|
||||
p.addCurve(
|
||||
to: CGPoint(x: 4, y: 20),
|
||||
control1: CGPoint(x: 12, y: 0),
|
||||
control2: CGPoint(x: 4, y: 8)
|
||||
)
|
||||
p.addLine(to: CGPoint(x: 4, y: height - 11))
|
||||
p.addCurve(
|
||||
to: CGPoint(x: 0, y: height),
|
||||
control1: CGPoint(x: 4, y: height - 1),
|
||||
control2: CGPoint(x: 0, y: height)
|
||||
)
|
||||
p.addLine(to: CGPoint(x: -0.05, y: height - 0.01))
|
||||
p.addCurve(
|
||||
to: CGPoint(x: 11.0, y: height - 4.0),
|
||||
control1: CGPoint(x: 4.0, y: height + 0.5),
|
||||
control2: CGPoint(x: 8, y: height - 1)
|
||||
)
|
||||
p.addCurve(
|
||||
to: CGPoint(x: 25, y: height),
|
||||
control1: CGPoint(x: 16, y: height),
|
||||
control2: CGPoint(x: 20, y: height)
|
||||
)
|
||||
}
|
||||
return p
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user