-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added API examples for calculateActorState, draw, redraw, and render.
- Loading branch information
1 parent
32c1306
commit f827338
Showing
5 changed files
with
199 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Rekapi example</title> | ||
<script src="../../dist/underscore.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(canvas, { | ||
'height': 300, | ||
'width': 400 | ||
}); | ||
|
||
var actor = new Kapi.Actor({ | ||
'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); | ||
actor | ||
.keyframe(0, { x: 50, y: 50 }) | ||
.keyframe(1000, { x: 200, y: 150 }); | ||
|
||
// This operation doesn't actually draw anything. It just calls | ||
// calculatePosition on all of the actors. | ||
kapi.calculateActorPositions(500); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Rekapi example</title> | ||
<script src="../../dist/underscore.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(canvas, { | ||
'height': 300, | ||
'width': 400 | ||
}); | ||
|
||
var actor = new Kapi.Actor({ | ||
'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); | ||
actor | ||
.keyframe(0, { x: 50, y: 50 }) | ||
.keyframe(1000, { x: 200, y: 150 }); | ||
|
||
// This is almost the same as calling kapi.render(500). No events are | ||
// fired with this approach, however. | ||
kapi.calculateActorPositions(500); | ||
kapi.draw(); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Rekapi example</title> | ||
<script src="../../dist/underscore.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(canvas, { | ||
'height': 300, | ||
'width': 400 | ||
}); | ||
|
||
var actor = new Kapi.Actor({ | ||
'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); | ||
actor | ||
.keyframe(0, { x: 50, y: 50 }) | ||
.keyframe(1000, { x: 200, y: 150 }); | ||
|
||
kapi.calculateActorPositions(500); | ||
kapi.draw(); | ||
kapi.canvas_clear(); | ||
|
||
setTimeout(function () { | ||
kapi.redraw(); | ||
}, 1000); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Rekapi example</title> | ||
<script src="../../dist/underscore.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(canvas, { | ||
'height': 300, | ||
'width': 400 | ||
}); | ||
|
||
var actor = new Kapi.Actor({ | ||
'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); | ||
actor | ||
.keyframe(0, { x: 50, y: 50 }) | ||
.keyframe(1000, { x: 200, y: 150 }); | ||
|
||
kapi.render(500); | ||
</script> | ||
</body> | ||
</html> |