-
Notifications
You must be signed in to change notification settings - Fork 0
/
image.html
82 lines (74 loc) · 2.86 KB
/
image.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
<!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/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;
var img = new Image();
img.src = 'http://placekitten.com/400/200';
me.img = new Kinetic.Image({
image: img,
x: me.sW / 2,
y: me.sH / 2,
width: 400,
height: 200,
offset: [200,100]
});
me.layer.add(me.img);
},
onFrame: function(frame) {
var me = this;
var posX = Math.cos(frame.time / 3000 * Math.PI * 2) * me.sW / 2 + me.sW / 2;
var posY = Math.sin(posX / me.sW * Math.PI) * me.sH / 2;
var rot = -((posX - me.sW / 2) / me.sW * Math.PI / 2);
me.img.setX(posX);
me.img.setY(posY);
me.img.setRotation(rot);
return;
}
})
Ext.onReady(function() {
var m = new Main({
stage: new Kinetic.Stage({
width: 800,
height: 480,
container: 'container'
}),
layer: new Kinetic.Layer()
});
})
</script>
</body>
</html>