-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
144 lines (115 loc) · 2.63 KB
/
Copy pathbackground.js
File metadata and controls
144 lines (115 loc) · 2.63 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
var partNum = 30;
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');
var w = window.innerWidth; var h = window.innerHeight;
var x = 100; var y = 100;
var particles = [];
for(i = 0; i < partNum; i++) {
particles.push(new newParticle);
}
function newParticle() {
this.x = w / 2;
this.y = h / 2;
this.vx = Math.random() * 20-10;
this.vy = Math.random() * 20-10;
this.r = Math.random() * 15;
var r = '#c0392b';
var o = '#e67e22';
var y = '#f1c40f';
var array = [r, o, y];
this.color = array[Math.floor(Math.random() * 3)];
this.g = 0.3;
}
var draw = function() {
c.width = w;
c.height = h;
for(t = 0; t < particles.length; t++) {
var p = particles[t];
ctx.beginPath();
ctx.fillStyle = p.color;
ctx.arc(p.x, p.y, p.r, Math.PI * 2, false);
ctx.fill();
p.x+=p.vx;
p.y+=p.vy+=p.g;
if(p.y < 0)
p.vy *= -1;
if(p.y > h)
p.vy *= -1;
if(p.y > h + 1)
p.y = h;
if(p.x < 0)
p.vx *= -1;
if(p.x > w)
p.vx *= -1;
if(p.r < 3) {
p.color = 'white';
};
}
};
setInterval(draw, 33);
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
$("p").each(function() {
var text = $(this).html();
var words = text.split(" ");
var spanSentence = "";
for (var i = 0; i < words.length; i++) {
spanSentence += "<span>" + words[i] + "</span> ";
}
$(this).html(spanSentence);
})
$("p span").each(function() {
$(this)
.css({
"transform": "translate(" + getRandomInt(-100, 100) + "px, " + getRandomInt(-100, 100) + "px)"
})
});
setTimeout(function() {
$("p:nth-child(1) span").css({
"transform": "translate(0, 0)",
"opacity": 1
});
}, 50);
setTimeout(function() {
$("p:nth-child(2) span").css({
"transform": "translate(0, 0)",
"opacity": 1
});
}, 1000+50);
setTimeout(function() {
$("p:nth-child(3) span").css({
"transform": "translate(0, 0)",
"opacity": 1
});
}, 2000+50);
setTimeout(function() {
$("p:nth-child(4) span").css({
"transform": "translate(0, 0)",
"opacity": 1
});
}, 3000+50);
setTimeout(function() {
$("p:nth-child(5) span").css({
"transform": "translate(0, 0)",
"opacity": 1
});
}, 4000+50);
setTimeout(function() {
$("p:nth-child(6) span").css({
"transform": "translate(0, 0)",
"opacity": 1
});
}, 5000+50);
setTimeout(function() {
$("p:nth-child(7) span").css({
"transform": "translate(0, 0)",
"opacity": 1
});
}, 6000+50);
setTimeout(function() {
$("p:nth-child(8) span").css({
"transform": "translate(0, 0)",
"opacity": 1
});
}, 8000+50);