forked from konstantinos-tsatsarounos/rainyday.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
95 lines (89 loc) · 3.52 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Rainy JS Demo</title>
<style media="screen">
body {
overflow-y: hidden;
}
#parent {
width: 100%;
height: 100%;
margin: 0 auto;
position: absolute;
top: 0;
left: 0;
}
#parent img {
width: 100%;
height: 100%;
}
</style>
<script src="rainyday.js"></script>
<script>
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 = null;
var preset = getURLParameter('preset') || '1';
if (preset === '1') {
engine = new RainyDay({
element: 'background',
crop: [200, 300, 600, 400],
blur: 10,
opacity: 1,
fps: 30
});
engine.trail = engine.TRAIL_SMUDGE;
engine.VARIABLE_GRAVITY_ANGLE = Math.PI / 9;
engine.rain([ [1, 0, 1], [3, 3, 3] ], 100);
} else if (preset === '2') {
engine = new RainyDay({
element: 'background',
blur: 10,
opacity: 1,
fps: 30
});
engine.VARIABLE_GRAVITY_ANGLE = Math.PI / 8;
engine.rain([ [0, 2, 1], [4, 4, 1] ], 50);
} else if (preset === '3') {
engine = new RainyDay({
element: 'background',
blur: 10,
opacity: 1,
fps: 30
});
engine.trail = engine.TRAIL_SMUDGE;
engine.rain([ [0, 2, 1], [4, 4, 1] ], 100);
}
};
image.crossOrigin = 'anonymous';
if (getURLParameter('imgur')) {
image.src = 'http://i.imgur.com/' + getURLParameter('imgur') + '.jpg';
} else if (getURLParameter('img')) {
image.src = getURLParameter('img') + '.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&loop=1';
div.appendChild(player);
}
}
</script>
</head>
<body onload="demo();">
<div id="sound" style="z-index: -1;"></div>
<div id="parent">
<img id="background" alt="background" src="" />
</div>
</body>
</html>