Skip to content

Commit

Permalink
cached context in a variable
Browse files Browse the repository at this point in the history
  • Loading branch information
zenorocha committed Mar 24, 2013
1 parent 9d48d8a commit 6a4256f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions examples/move_controller_single_pixels.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
<body>

<script>
var videoCamera = new tracking.VideoCamera().hide().render().renderVideoCanvas();
var videoCamera = new tracking.VideoCamera().hide().render().renderVideoCanvas(),
ctx = videoCamera.canvas.context;

videoCamera.track({
type: 'color',
Expand All @@ -36,12 +37,12 @@
var pixels = track.pixels;

for (var i = 0, len = pixels.length; i < len; i += 2) {
videoCamera.canvas.context.fillStyle = "rgb(255,0,255)";
videoCamera.canvas.context.fillRect(pixels[i], pixels[i+1], 2, 2);
ctx.fillStyle = "rgb(255,0,255)";
ctx.fillRect(pixels[i], pixels[i+1], 2, 2);
}

videoCamera.canvas.context.fillStyle = "rgb(0,0,0)";
videoCamera.canvas.context.fillRect(track.x, track.y, 5, 5);
ctx.fillStyle = "rgb(0,0,0)";
ctx.fillRect(track.x, track.y, 5, 5);
}
});
</script>
Expand Down

0 comments on commit 6a4256f

Please sign in to comment.