Skip to content

Instantly share code, notes, and snippets.

@michaelevensen
Created January 18, 2023 21:08
Show Gist options
  • Save michaelevensen/6f05a012877b4c3dfcda5eaaeaae83ce to your computer and use it in GitHub Desktop.
Save michaelevensen/6f05a012877b4c3dfcda5eaaeaae83ce to your computer and use it in GitHub Desktop.
Draws a funky Circle. Probably better to do this as a custom `Shape`?
struct CircleView: View {
@State var spacing: Double = 12
var radius: Double = 250
var body: some View {
GeometryReader { proxy in
let center = CGPoint(x: proxy.frame(in: .local).midX, y: proxy.frame(in: .local).midY)
Path { path in
let circle = 2.0 * Double.pi
for angle in stride(from: 0.0, to: circle, by: circle / (360 / spacing)) {
let x = radius * cos(angle)
let y = radius * sin(angle)
path.move(to: center)
path.addLine(to: CGPoint(x: center.x + x, y: center.y + y))
}
}
.stroke(.white, lineWidth: 1.5)
}
.background(.black)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment