-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathball.html
42 lines (40 loc) · 1.43 KB
/
ball.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div class='mousetest' style='background: #fff;width:1000px;height:1000px'>
</div>
</body>
<script src='ui-animal.js'></script>
<script>
var panelElem = document.querySelector('.mousetest') ;
function mouseMoveAnimation(panelElem){
var nowTime = 60 ;
var preTime = 0 ;
var timeInterval = 30;
panelElem.onmousemove = function(e,type){
nowTime = new Date().getTime();
if(nowTime-preTime>=timeInterval){
// 更新时间
preTime = nowTime;
nowTime = new Date().getTime();
// 创建画布
var canvas = createCanvasDraw(panelElem,100,100,e.clientX-50,e.clientY-50);
var cxt = new CanvasDraw(canvas);
var colorStr = 'rgba('+rn()+','+rn()+','+rn()+','
animate(0,Math.random()*30+10,800,{math:'Quint',type:'easeOut'},function(value,time){
cxt.clear(100,100).drawBall(50,50,value,colorStr+(0.4-time/800*0.4)+')')
},function(){
panelElem.removeChild(canvas);
})
}
}
}
mouseMoveAnimation(panelElem)
</script>
</html>