-
Notifications
You must be signed in to change notification settings - Fork 72
/
get_actor.html
45 lines (40 loc) · 1.09 KB
/
get_actor.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
<!doctype html>
<html>
<head>
<title>Rekapi example</title>
<script src="../../dist/_.js"></script>
<script src="../../dist/shifty.js"></script>
<script src="../../dist/rekapi.js"></script>
</head>
<body>
<canvas></canvas>
<script>
var canvas = document.getElementsByTagName('canvas')[0];
var kapi = new Kapi({
'context': canvas,
'height': 300,
'width': 400
});
var actor = new Kapi.CanvasActor({
'draw': function (canvas_context, state) {
canvas_context.beginPath();
canvas_context.arc(
state.x || 0,
state.y || 0,
state.radius || 50,
0,
Math.PI*2,
true);
canvas_context.fillStyle = state.color || '#f0f';
canvas_context.fill();
canvas_context.closePath();
return this;
}
});
kapi.addActor(actor);
var retrievedActor = kapi.getActor(0);
console.log(retrievedActor);
console.log(actor === retrievedActor);
</script>
</body>
</html>