Skip to content

Commit

Permalink
fix clipping background to be transparent, not white
Browse files Browse the repository at this point in the history
  • Loading branch information
schanzer committed Apr 1, 2013
1 parent d42619f commit 937b21a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions js-runtime/lib/world/world.js
Expand Up @@ -348,15 +348,16 @@ if (typeof(world) === 'undefined') {
SceneImage.prototype.render = function(ctx, x, y) {
var i;
var childImage, childX, childY;
// create a clipping region around the boundaries of the Scene
ctx.save();
ctx.fillStyle="white";
ctx.fillStyle = "rgba(0,0,0,0)";
ctx.fillRect(x, y, this.width, this.height);
ctx.restore();
ctx.save();
ctx.rect(x, y, this.width, this.height);
ctx.clip();

// Ask every object to render itself.
// Ask every object to render itself inside the region
for(i = 0; i < this.children.length; i++) {
// then, render the child images
childImage = this.children[i][0];
Expand All @@ -365,8 +366,9 @@ if (typeof(world) === 'undefined') {
childImage.render(ctx, childX + x, childY + y);
}

// unclip
ctx.restore();
// Finally, draw the black border if withBorder is true

if (this.withBorder) {
ctx.strokeStyle = 'black';
ctx.strokeRect(x, y, this.width, this.height);
Expand Down

0 comments on commit 937b21a

Please sign in to comment.