Mode:
Duration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import SwiftUI
struct ContentView: View {
let rows = 25
let cols = 25
var body: some View {
Canvas { context,size in
let cell = size.width/CGFloat(cols)
for r in 0..<rows {
for c in 0..<cols {
if Bool.random() {
context.fill(Path(CGRect(x:CGFloat(c)*cell,y:CGFloat(r)*cell,width:cell-1,height:cell-1)),with:.color(.green))
}
}
}
}
}
}Coding works best on desktop or with an external keyboard.