-
Notifications
You must be signed in to change notification settings - Fork 0
/
utilities.js
51 lines (41 loc) · 1.42 KB
/
utilities.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
// Useful stuff
function updateCanvasDimensions(canvas) { // Strecth canvas to window
canvas.attr({ height: $(window).height(), width: $(window).width() });
}
function rainbow() {
S(document.body).backgroundColor = "hsl(" + color + ", 55%, 30%)";
color++;
color %= 360;
}
function svgButton() {
S('inner').fill = "hsl(" + colorInner + ", 55%, 50%)";
S('outer').fill = "hsl(" + colorOuter + ", 55%, 20%)";
colorInner++;
colorInner %= 360;
colorOuter--;
colorOuter %= 360;
}
function buttonDimensions(height) {
radius = Math.floor(height / 14); // Bomber Lino
S('svgButton').height = radius * 2;
S('svgButton').width = radius * 2;
S('inner').cx = radius;
S('inner').cy = radius;
S('inner').r = radius - radius * 0.25;
S('outer').cx = radius;
S('outer').cy = radius;
S('outer').r = radius;
}
// The timestamp parameter is passed automatically, holds the time passed from the loading of the page
// in milliseconds and decimals
function animate(timestamp) {
SM.clear();
SM.drawAll(timestamp); // Sentence updating
if (timestamp > lastColorUpdate + 400) {
rainbow(); // Background color updating
svgButton();
//drawButton(O('c'), fSM.canvasHeight, fSM.canvasWidth); // Draw button as last thing
lastColorUpdate = timestamp;
}
requestAnimationFrame(animate) // call requestAnimationFrame again to animate next frame
}