-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathutil.js
34 lines (29 loc) · 954 Bytes
/
util.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
// returns a random integer between 0 and n-1
function randomInt(n) {
return Math.floor(Math.random() * n);
};
// returns a string that can be used as a rgb web color
function rgb(r, g, b) {
return "rgb(" + r + "," + g + "," + b + ")";
};
// returns a string that can be used as a hsl web color
function hsl(h, s, l) {
return "hsl(" + h + "," + s + "%," + l + "%)";
};
// creates an alias for requestAnimationFrame for backwards compatibility
window.requestAnimFrame = (function () {
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function (/* function */ callback, /* DOMElement */ element) {
window.setTimeout(callback, 1000 / 60);
};
})();
// add global parameters here
const PARAMS = {
DEBUG: true,
SCALE: 3,
BITWIDTH: 16
};