-
Notifications
You must be signed in to change notification settings - Fork 0
/
2015-09-02.html
121 lines (114 loc) · 3.14 KB
/
2015-09-02.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
<!doctype html>
<html>
<head>
<title>2015/09/02</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
<style>
html, body {
height: 100%;
padding: 0;
margin: 0;
}
#canvas {
display: block;
cursor: none;
/*background: #000;*/
}
.sign {
position: absolute;
bottom: 20px;
right: 20px;
font-size: 14px;
color: black;
font-style: italic;
}
#doujia {
position: absolute;
top: 50%;
left: 50%;
font-size: 20px;
margin-left: -43px;
margin-top: -16px;
color: royalblue;
}
.help {
position: absolute;
bottom: 20px;
left: 20px;
color: black;
font-size: 12px;
text-decoration: underline;
}
#position {
position: absolute;
top: 20px;
left: 20px;
color: black;
font-size: 12px;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<div class="sign">Beyond</div>
<div id="doujia">
Doujia<br>
I love you
</div>
<div class="help">
Touch the screen to see the effect
</div>
<div id="position">
</div>
<script type="text/javascript" src="https://code.createjs.com/easeljs-0.8.1.min.js"></script>
<script>
+function() {
var stage = new createjs.Stage("canvas");
var center = {};
var cur = {};
function Path() {
// this.radius = 100;
// this.angle = 0;
this.x = center.x;
this.y = center.y;
this.velocity = 2;
}
Path.prototype.update = function() {
cur.x = stage.mouseX
cur.y = stage.mouseY;
var disX = cur.x - this.x;
var disY = cur.y - this.y;
var dis = Math.sqrt(disX * disX + disY * disY);
if (dis) {
this.x += this.velocity * disX / dis;
this.y += this.velocity * disY / dis;
stage.addChild(new Point(this.x, this.y));
stage.update();
}
};
function Point(x, y) {
var point = new createjs.Shape();
point.graphics.beginFill("#ff7700").drawCircle(x, y, 2);
return point;
}
function init() {
var canvas = document.getElementById('canvas');
var width = document.body.clientWidth;
var height = document.body.clientHeight;
center.x = width / 2;
center.y = height / 2;
cur.x = width / 2;
cur.y = 0;
canvas.setAttribute('width', width);
canvas.setAttribute('height', height);
var path = new Path();
createjs.Ticker.setFPS(60);
createjs.Ticker.addEventListener("tick", function() {
path.update();
});
}
window.onload = init;
}();
</script>
</body>
</html>