-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
55 lines (43 loc) · 1.08 KB
/
script.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
let sampleImage;
let canvas;
let WFC;
let readyToGenerate = false;
let finished = false;
let steps = 100;
let avg_steps = 0;
let rendered_frames = 0;
let url_params;
let drawCell;
function setup() {
canvas = createCanvas(windowWidth, windowHeight);
// randomSeed(0);
url_params = getURLParams();
displayBackgroundTiles = Number(url_params.dbt || "0");
createDrawCell();
const imagePath = `data/${url_params.pattern || "demo-3"}.png`;
sampleImage = loadImage(imagePath, createField, () => {
alert("Image couldn't be loaded );");
});
}
function draw() {
if (readyToGenerate) {
let time_start = performance.now();
for (let row of WFC.grid) for (let elt of row) elt.display();
let i = 0;
if (!finished)
while (i++ < 1000) {
WFC.updateStep();
if (i % 10 == 0) if (performance.now() - time_start > 33.3) break;
}
avg_steps += i;
// WFC.updateChunk();/
rendered_frames++;
// if (finished) {
// randomSeed(0);
// createField();
// finished = !finished;
// }
} else {
background(0, 10, 60);
}
}