From 937b21a65d885cc43f2615ff8668bae543c08a32 Mon Sep 17 00:00:00 2001 From: Emmanuel Schanzer Date: Mon, 1 Apr 2013 16:04:30 -0700 Subject: [PATCH] fix clipping background to be transparent, not white --- js-runtime/lib/world/world.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/js-runtime/lib/world/world.js b/js-runtime/lib/world/world.js index 78a4f57..11d8e57 100644 --- a/js-runtime/lib/world/world.js +++ b/js-runtime/lib/world/world.js @@ -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]; @@ -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);