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
var path = Path()
let cx = size.width/2
let cy = size.height/2
for i in stride(from: 0.0, through: Double.pi*2, by: 0.01) {
let x = cx + CGFloat(sin(3*i) * 140)
let y = cy + CGFloat(sin(4*i) * 140)
i == 0 ? path.move(to: CGPoint(x: x, y: y)) : path.addLine(to: CGPoint(x: x, y: y))
}
context.stroke(path, with: .color(.blue), lineWidth: 2)
}
}
}Coding works best on desktop or with an external keyboard.