-
Notifications
You must be signed in to change notification settings - Fork 0
/
2015-08-29.html
60 lines (59 loc) · 2.26 KB
/
2015-08-29.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
<!doctype html>
<html>
<head>
<title>2015/08/29</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
<style>
canvas {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate3d(-50%, -50%, 0);
transform: translate3d(-50%, -50%, 0);
}
</style>
</head>
<body>
<canvas id="demoCanvas"></canvas>
<script src="https://code.createjs.com/easeljs-0.8.1.min.js"></script>
<script src="https://code.createjs.com/tweenjs-0.6.1.min.js"></script>
<script>
+function() {
var demoCanvas = document.getElementById('demoCanvas');
var width = document.body.clientWidth;
var height = 300;
demoCanvas.setAttribute('width', width);
demoCanvas.setAttribute('height', height);
var colors = ["#ff7700", "#008B8B", "#E9967A", "#00BFFF", "#8470FF",
"#66CDAA", "#C71585", "#FFC0CB", "#B0E0E6", "#EE82EE"];
function circle(stage, index) {
var circle = new createjs.Shape();
circle.graphics.beginFill(colors[index]).drawCircle(0, 0, 10);
circle.x = width * 0.2;
circle.y = height * 0.2;
stage.addChild(circle);
createjs.Tween.get(circle, { loop: true })
.wait(index * 100)
.to({ x: width * 0.8}, 1000, createjs.Ease.getPowInOut(2))
.to({ alpha: 1, y: height * 0.8}, 500, createjs.Ease.getPowInOut(2))
.to({ x: width * 0.2 }, 800, createjs.Ease.getPowInOut(2))
.to({ x: width * 0.2, y: height * 0.2 }, 800, createjs.Ease.getPowInOut(2))
}
function init() {
var stage = new createjs.Stage("demoCanvas");
var text = new createjs.Text('Hi Doujia\nI love you', "20px Arial", "#ff7700");
text.x = width * 0.5 - 40;
text.y = 150;
text.textBaseline = "alphabetic";
stage.addChild(text);
for (var i = 0; i < 10; i++) {
circle(stage, i);
}
createjs.Ticker.setFPS(60);
createjs.Ticker.addEventListener("tick", stage);
}
window.onload = init;
}();
</script>
</body>
</html>