Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Created January 26, 2021 04:31
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/1ec25b98a3b055db901809df7f035b44 to your computer and use it in GitHub Desktop.
Save sturdysturge/1ec25b98a3b055db901809df7f035b44 to your computer and use it in GitHub Desktop.
import SwiftUI
struct AquaBrushedMetalShape: Shape {
func path(in rect: CGRect) -> Path {
Path {
path in for _ in stride(from: 0, to: Int(rect.height), by: 5) {
let y = CGFloat.random(in: rect.minY...rect.maxY)
let curveEnd = CGPoint(x: rect.maxX, y: y)
let controlOffset = CGFloat.random(in: -25...25)
let controlPoint = CGPoint(x: rect.midX, y: y + controlOffset)
path.move(to: CGPoint(x: rect.minX, y: y))
path.addQuadCurve(to: curveEnd, control: controlPoint)
}
}
}
}
struct AquaBrushedMetalView: View {
let gradient = Gradient(
colors: [.aquaTransparentWhite,
.aquaTranslucentWhite,
.aquaTransparentWhite])
var body: some View {
ZStack {
Color.aquaGray
AquaBrushedMetalShape()
.stroke(Color.aquaBrushedMetalStroke, lineWidth: 2)
LinearGradient(gradient: gradient ,
startPoint: .leading,
endPoint: .trailing)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment