Mode:
Duration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import SwiftUI
struct ContentView: View {
var body: some View {
Canvas { context, size in
let center = CGPoint(x: size.width/2, y: size.height/2)
var path = Path()
for t in stride(from: 0.0, through: Double.pi*8, by: 0.01) {
let r = 150*cos(5*t)
let x = center.x + CGFloat(r*cos(t))
let y = center.y + CGFloat(r*sin(t))
t == 0 ? path.move(to: CGPoint(x:x,y:y)) : path.addLine(to: CGPoint(x:x,y:y))
}
context.stroke(path, with: .color(.pink), lineWidth: 2)
}
}
}Coding works best on desktop or with an external keyboard.