forked from konstantinos-tsatsarounos/rainyday.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
59 lines (55 loc) · 2.12 KB
/
demo.html
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
<html>
<head>
<style media="screen" type="text/css">
img { display: none; }
body { overflow: hidden; }
#canvas { position: absolute; top: 0px; left: 0px; }
</style>
<script src="rainyday.js" type="text/javascript"></script>
<script type="text/javascript">
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
}
function demo() {
var image = document.getElementById('background');
image.onload = function() {
var engine = new RainyDay('canvas','background', window.innerWidth, window.innerHeight);
var preset = getURLParameter("preset") || 1;
if (preset == 1) {
engine.gravity = engine.GRAVITY_NON_LINEAR;
engine.trail = engine.TRAIL_DROPS;
engine.rain([ engine.preset(3, 3, 0.88), engine.preset(5, 5, 0.9), engine.preset(6, 2, 1) ], 100);
} else if (preset == 2) {
engine.gravity = engine.GRAVITY_NON_LINEAR;
engine.trail = engine.TRAIL_DROPS;
engine.VARIABLE_GRAVITY_ANGLE = Math.PI / 8;
engine.rain([ engine.preset(0, 2, 0.5), engine.preset(4, 4, 1) ], 50);
} else if (preset == 3) {
engine.gravity = engine.GRAVITY_NON_LINEAR;
engine.trail = engine.TRAIL_SMUDGE;
engine.rain([ engine.preset(0, 2, 0.5), engine.preset(4, 4, 1) ], 50);
}
};
image.crossOrigin = "anonymous";
image.src="http://i.imgur.com/" + getURLParameter('imgur') + ".jpg";
var youtube = getURLParameter("youtube");
if (youtube) {
var div = document.getElementById("sound");
var player = document.createElement('iframe');
player.frameborder = "0";
player.height = "1";
player.width = "1";
player.src = "https://youtube.com/embed/" + youtube + "?autoplay=1&controls=0&showinfo=0&autohide=1";
div.appendChild(player);
}
}
</script>
</head>
<body onload="demo();">
<div id="sound" style="z-index: -1;"></div>
<img id="background" src="" />
<div id="cholder">
<canvas id="canvas"></canvas>
</div>
</body>
</html>