-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow_love.html
189 lines (177 loc) · 5.71 KB
/
show_love.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
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Show You&Me</title>
<!--<link rel="shortcut icon" href="favicon.ico">-->
<audio src="bg-music.mp3" autoplay=""></audio>
<style>
body{
overflow:hidden;
margin:0;
background-color: blanchedalmond;
}
/*h1{*/
/*position:fixed;*/
/*top:50%;*/
/*left:0;*/
/*width:100%;*/
/*text-align:center;*/
/*line-height: 50px;*/
/*transform:translateY(-50%);*/
/*font-family: 'Love Ya Like A Sister', cursive;*/
/*font-size: 40px;*/
/*color: #f17c67;*/
/*padding:0 20px;*/
/*}*/
div{
position:fixed;
top:50%;
left: 20%;
width: 60%;
text-align:center;
line-height: 80px;
transform:translateY(-50%);
font-family: 'Love Ya Like A Sister', cursive;
font-size: 40px;
color: #f17c67;
padding:0 20px;
}
/*h1:after {*/
/*content: "|";*/
/*opacity: 1;*/
/*animation: caret 500ms infinite;*/
/*}*/
h1 span{
font-size: 20px;
}
</style>
</head>
<body>
<div id="aa" class="saying">
<h1 id="h1" style="display:none"></h1>
</div>
<canvas></canvas>
<script>
var canvas=document.querySelector('canvas'),
ctx=canvas.getContext('2d');
var ww, wh;
function onResize() {
ww=canvas.width=window.innerWidth;
wh=canvas.height=window.innerHeight;
}
ctx.strokeStyle='red';
ctx.shadowBlur=25;
ctx.shadowColor='hsla(0,100%,60%,0.5)';
var precesion=200;
var hearts=[];
var mouseMoved= false;
function onMove(e) {
mouseMoved=true;
if(e.type==='touchmove'){
hearts.push(new Heart(e.touches[0].clientX, e.touches[0].clientY));
hearts.push(new Heart(e.touches[0].clientX, e.touches[0].clientY));
}else{
hearts.push(new Heart(e.clientX, e.clientY));
hearts.push(new Heart(e.clientX, e.clientY));
}
}
var Heart=function (x,y) {
this.x=x||Math.random()*ww;
this.y=y||Math.random()*wh;
this.size=Math.random()*2+1;
this.shadowBlur=Math.random()*10;
this.speedX=(Math.random()+0.2-0.6)*8;
this.speedY=(Math.random()+0.2-0.6)*8;
this.speedSize=Math.random()*0.05+0.01;
this.opacity=1;
this.vertices=[];
for(var i=0; i<precesion; i++){
var step=(i/precesion-0.5)*(Math.PI*2);
var vector={
// x:(15 * Math.pow(Math.sin(step),3));
// y:-(13 * Math.cos(step)-5*Math.cos(2*step)-2*Math.cos(3*step)-Math.cos(4*step));
x : (15 * Math.pow(Math.sin(step), 3)),
y : -(13 * Math.cos(step) - 5 * Math.cos(2 * step) - 2 * Math.cos(3 * step) - Math.cos(4 * step))
};
this.vertices.push(vector);
}
};
Heart.prototype.draw=function () {
this.size-=this.speedSize;
this.x+=this.speedX;
this.y+=this.speedY;
ctx.save();
ctx.translate(-1000,this.y);
ctx.scale(this.size,this.size);
ctx.beginPath();
for (var i=0; i<precesion; i++){
var vector=this.vertices[i];
ctx.lineTo(vector.x,vector.y);
}
ctx.globalAlpha=this.size;
ctx.shadowBlur=Math.round((3-this.size)*10);
ctx.shadowColor='hsla(0,100%,60%,0.5)';
ctx.shadowOffsetX=this.x+1000;
ctx.globalCompositeOperation='screen';
ctx.closePath();
ctx.fill();
ctx.restore();
};
function render(a) {
requestAnimationFrame(render);
hearts.push(new Heart());
ctx.clearRect(0,0,ww,wh);
for(var i=0;i<hearts.length; i++){
hearts[i].draw();
if(hearts[i].size<=0){
hearts.splice(i,1);
i--;
}
}
}
onResize();
window.addEventListener('mousemove',onMove);
window.addEventListener('touchmove',onMove);
window.addEventListener('resize',onResize);
requestAnimationFrame(render);
time(h1,'2016,4,9');
window.setInterval(function(){
time(h1,'2016,4,9');
},1000);
function time(obj,futimg) {
var nowTime=new Date().getTime();
var futrueTime=new Date(futimg).getTime();
var msec=nowTime-futrueTime;
var time=(msec/1000);
var day=parseInt(time/86400);
var hour = parseInt(time/3600)-24*day;
var minute=parseInt(time%3600/60);
var second=parseInt(time%60);
obj.innerHTML=
"亮哥,知道我们在一起多久了吗? " +
" 从我们认识到现在已经:"+day+"天"+hour+"小时"+minute+"分"+second+"秒"+"了。" +
"一时间不知道从哪说起,真爱来了,我们要好好把握。" +
"不管面临多大的压力,不管前面的路如何崎岖。" +
"不管经历过什么,我仍坚信最浪漫的事就是和你一起慢慢变老。" +
"相信中间的计时器,将永远继续下去,直至数据溢出。";
return true;
}
var index=0;
var word;
function type(){
var typePanel = document.getElementById("aa");
typePanel.innerText = word.substring(0,index++);
if(index % 3 == 0){
typePanel.className = "";
}else if(index % 3 == 1){
typePanel.className = "saying";
}
}
window.onload=function(){
word=document.getElementById("h1").innerHTML;
setInterval(type, 200);
};
</script>
</body>
</html>