Permalink
Browse files

Adds example for playFromCurrent.

  • Loading branch information...
1 parent b097b0d commit 273ec32cc590128dcdd378438a2a38a586614966 @jeremyckahn committed Apr 19, 2012
Showing with 53 additions and 0 deletions.
  1. +2 −0 docs/api.kapi.md
  2. +51 −0 docs/examples/play_from_current.html
View
@@ -140,6 +140,8 @@ Kapi.prototype.playFromCurrent (opt_howManyTimes)
Play from the last frame that was drawn with `render()`. `opt_howManyTimes` works as it does in `play()`.
+__[Example](examples/play_from_current.html)__
+
### pause
@@ -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 });
+
+ // Show the animation at 500 milliseconds...
+ kapi.render(500);
+
+ setTimeout(function () {
+ // ... and then play twice from there.
+ kapi.playFromCurrent(2);
+ }, 750);
+ </script>
+ </body>
+</html>

0 comments on commit 273ec32

Please sign in to comment.