-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
105 lines (92 loc) · 2.86 KB
/
test.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
Remove this if you use the .htaccess -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>block</title>
<meta name="description" content="" />
<meta name="author" content="PRO11_6" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references -->
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<style type="text/css">
* { margin: 0; padding: 0;}
body {
overflow: hidden;
}
canvas {
border: 1px solid red;
}
</style>
</head>
<body>
<div id="container"></div>
<script type="text/javascript" src="src/ext-core.js"></script>
<script type="text/javascript" src="src/kinetic.latest.js"></script>
<script type="text/javascript" src="src/transitionTo.js"></script>
<script type="text/javascript" src="src/base.js"></script>
<script type="text/javascript">
Main = Ext.extend(Ext.Base, {
autoStart: true,
constructor: function() {
Main.superclass.constructor.apply(this, arguments);
},
initScene: function() {
Main.superclass.initScene.apply(this, arguments);
var me = this;
me.circles = [];
for(var i = 0; i < 10; i++) {
me.circles.push(me.addCircle());
}
},
addCircle: function() {
var me = this;
var c = new Kinetic.Circle({
fill: '#'+(Math.random() * 0xFFFFFF << 0).toString(16),
radius: 20,
x: Math.random() * (me.sW - 20) + 20,
y: Math.random() * (me.sH - 20) + 20
});
c.offsetX = c.offsetY = 0;
me.layer.add(c);
return c;
},
onFrame: function(frame) {
var me = this,
circles = me.circles,
cLen = circles.length,
mouse = me.mouse;
for(var i = 0; i < cLen; i++) {
var c1 = circles[i];
var a = Math.atan2(mouse.y - c1.attrs.y, mouse.x - c1.attrs.x);
for(var j = i + 1; j < cLen; j++) {
var c2 = circles[j];
var pos = Math.sqrt(Math.pow(mouse.x - c2.attrs.x, 2) + (mouse.y - c2.attrs.y, 2));
if(pos < 40) {
c2.attrs.x += (c2.attrs.x < c1.attrs.x) ? -40 : 40;
c2.attrs.y += (c2.attrs.y < c1.attrs.y) ? -40 : 40;
}
}
var posX = c1.attrs.x + (mouse.x - c1.attrs.x) * 0.02;
var posY = c1.attrs.y + (mouse.y - c1.attrs.y) * 0.02;
c1.setX(posX);
c1.setY(posY);
}
}
});
Ext.onReady(function() {
var m = new Main({
stage: new Kinetic.Stage({
width: 1280,
height: 480,
container: 'container'
}),
layer: new Kinetic.Layer()
});
})
</script>
</body>
</html>