forked from SORCEway/SORCEway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhintergrund_paprika.js
80 lines (68 loc) · 2.68 KB
/
hintergrund_paprika.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
function P_A_P_R_I_K_A(count) {
let canvas = document.createElement("canvas");
canvas.style.position = "fixed";
canvas.style.top = 0;
canvas.style.left = 0;
canvas.style.zIndex = -1;
canvas.width = document.body.clientWidth;
canvas.height = document.body.clientHeight;
document.body.insertBefore(canvas, document.body.firstChild);
let img = new Image();
let ctx = canvas.getContext("2d");
let i = 0;
let freedoms = new Array(count);
function randInt(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
function rand(min, max) {
return Math.random() * (max - min) + min;
}
function draw() {
ctx.fillStyle = "red";
ctx.fillRect(0, 0, canvas.width, canvas.height);
for (let i = 0; i < freedoms.length; i++) {
if (typeof freedoms[i] == "undefined") {
let pos = randInt(-canvas.height, canvas.width);
freedoms[i] = {
x: (pos < 0) ? 0 : pos,
y: (pos < 0) ? -pos : 0,
scale: rand(0.4, 1.3),
speed: rand(0.5, 6),
angle: rand(-0.2, 0.2)
};
}
let freedom = freedoms[i];
let width = img.width * freedom.scale;
let height = img.height * freedom.scale;
ctx.drawImage(img, freedom.x - width, freedom.y - height, width, height);
freedom.x += freedom.speed * (1+freedom.angle);
freedom.y += freedom.speed * (1-freedom.angle);
if (freedom.x >= canvas.width+width || freedom.y >= canvas.height+height) {
// ACHTUNG TRIGGERWARNUNG
// FREIHEITSVERWEIGERNDER CODE
// ACHTUNG ACHTUNG ACHTUNG ACHTUNG OBACHT GEFAHR
// WEITERLESEN AUF EIGENE GEFAHR
// DIE ENTWICKLER VON SORCEWAY RESPEKTIEREN ALLE FREIHEITEN
// DIESER CODE IST **NICHT** ALS BILLIGUNG FÜR PROPRIETÄRE SOFTWARE ZU VERSTEHEN
//
//
//
//
delete freedoms[i] // STOP STOP STOP STOP STOP
//
//
//
//
// ENDE DER FREIHEITSVERWEIGERNDEN SEKTION
// DIE ENTWICKLER VON SORCEWAY ENTSCHULDIGEN SICH BEI IHNEN FÜR DIE ENTSTANDENEN UNANNEHMLICHKEITEN
}
}
window.requestAnimationFrame(draw);
}
img.src = "___FREIHEIT___.png";
img.onload = draw;
window.addEventListener("resize", () => {
canvas.width = document.body.clientWidth;
canvas.height = document.body.clientHeight;
})
};