-
Notifications
You must be signed in to change notification settings - Fork 0
/
handler.js
45 lines (37 loc) · 1.13 KB
/
handler.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
function init() {
var dotsInput = document.getElementById("dots-input");
var mulitplierInput = document.getElementById("multiplier-input");
var dotsSpan = document.getElementById("dots");
var multiplierSpan = document.getElementById("multiplier");
dotsInput.value = nrOfDots;
mulitplierInput.value = multiplier;
dotsSpan.innerText = nrOfDots;
multiplierSpan.innerText = multiplier;
window.addEventListener("resize", onWindowResize);
onWindowResize();
}
function nrOfDotsChanged(value) {
nrOfDots = value;
document.getElementById("dots").innerText = value;
draw();
}
function multiplierChanged(value) {
multiplier = value;
document.getElementById("multiplier").innerText = value;
draw();
}
function onWindowResize() {
var canvas = document.getElementById('canvas');
var width = window.innerWidth;
var height = window.innerHeight;
if (width * 1.2 > height) {
// Landscape
canvas.width = height - 120;
canvas.height = height - 120;
} else {
// Portrait
canvas.width = width;
canvas.height = width;
}
draw();
}