Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Created January 26, 2021 20:27
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 sturdysturge/0ea48efc3a5a713ac343b826421560a9 to your computer and use it in GitHub Desktop.
Save sturdysturge/0ea48efc3a5a713ac343b826421560a9 to your computer and use it in GitHub Desktop.
struct AquaWaveShape: Shape {
func path(in rect: CGRect) -> Path {
Path {
path in
path.move(to: CGPoint(x: rect.minX, y: rect.maxY * 0.9))
path.addQuadCurve(to: CGPoint(x: rect.maxX * 0.25, y: rect.midY),
control: CGPoint(x: rect.minX, y: rect.midY))
path.addLine(to: CGPoint(x: rect.maxX * 0.75, y: rect.midY))
path.addQuadCurve(to: CGPoint(x: rect.maxX, y: rect.maxY * 0.1),
control: CGPoint(x: rect.maxX, y: rect.midY))
path.addLine(to: CGPoint(x: rect.maxX, y: rect.minY))
path.addLine(to: CGPoint(x: rect.minX, y: rect.minY))
path.addLine(to: CGPoint(x: rect.minX, y: rect.maxY))
}
}
}
struct AquaWaveView: View {
var body: some View {
ZStack {
LinearGradient(gradient: Gradient(colors: [.gray, .white]),
startPoint: .top, endPoint: .bottom)
Color.aquaLightGray
.mask(AquaWaveShape())
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment