-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
37 lines (30 loc) · 812 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
let size = 4;
let takuzu;
function setup() {
createCanvas(400, 400);
frameRate(10);
takuzu = new Takuzu(size);
}
function draw() {
clear();
for(let i = 0; i < size ** 2; i++) {
let row = Math.floor(i / size);
let col = i % size;
let cell = takuzu.grid.getCell(row, col);
if(cell.value === null) {
noFill();
} else if(cell.value) {
fill(30, 144, 255);
} else {
fill(255, 99, 71);
}
square(col * (width / size), row * (height / size), width / size);
}
stroke(255);
noFill();
square(0, 0, width);
for(let i = 1; i < size; i++) {
line(width / (size / i), 0, width / (size / i), height);
line(0, height / (size / i), width, height / (size / i));
}
}