Created
January 18, 2023 21:08
-
-
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`?
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
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