image: Make transparency work FIXES #37

This commit is contained in:
Vishesh Yadav 2015-06-08 21:27:38 -04:00
parent ed08271fdf
commit 142baeb2ed
2 changed files with 9 additions and 11 deletions

View File

@ -487,8 +487,8 @@ EXPORTS['overlay/offset'] =
var middleY = (img1.getHeight() - img2.getHeight()) / 2; var middleY = (img1.getHeight() - img2.getHeight()) / 2;
return makeOverlayImage(img1, return makeOverlayImage(img1,
img2, img2,
jsnums.toFixnum(middleX + deltaX), jsnums.toFixnum(middleX) + deltaX,
jsnums.toFixnum(middleY + deltaY)); jsnums.toFixnum(middleY) + deltaY);
}); });
@ -569,8 +569,8 @@ EXPORTS['underlay/offset'] =
var middleY = (img1.getHeight() - img2.getHeight()) / 2; var middleY = (img1.getHeight() - img2.getHeight()) / 2;
return makeOverlayImage(img2, return makeOverlayImage(img2,
img1, img1,
-jsnums.toFixnum(middleX + deltaX), -(jsnums.toFixnum(middleX) + deltaX),
-jsnums.toFixnum(middleY + deltaY)); -(jsnums.toFixnum(middleY) + deltaY));
}); });
EXPORTS['underlay/align'] = EXPORTS['underlay/align'] =

View File

@ -45,14 +45,12 @@ var isColorOrColorString = function(thing) {
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// colorString : hexColor Style -> rgba // colorString : hexColor -> rgba
// Style can be "solid" (1.0), "outline" (1.0), a number (0-1.0) or null (1.0) var colorString = function(aColor) {
var colorString = function(aColor, aStyle) {
var alpha = isNaN(aStyle)? 1.0 : aStyle/255;
return "rgba(" + colorRed(aColor) + "," + return "rgba(" + colorRed(aColor) + "," +
colorGreen(aColor) + ", " + colorGreen(aColor) + ", " +
colorBlue(aColor) + ", " + colorBlue(aColor) + ", " +
alpha + ")"; (colorAlpha(aColor) || 255)/255.0 + ")";
}; };
@ -163,7 +161,7 @@ BaseImage.prototype.render = function(ctx, x, y) {
ctx.strokeStyle = colorString(this.color); ctx.strokeStyle = colorString(this.color);
ctx.stroke(); ctx.stroke();
} else { } else {
ctx.fillStyle = colorString(this.color, this.style); ctx.fillStyle = colorString(this.color);
ctx.fill(); ctx.fill();
} }
ctx.restore(); ctx.restore();
@ -1211,7 +1209,7 @@ EllipseImage.prototype.render = function(ctx, aX, aY) {
ctx.stroke(); ctx.stroke();
} }
else { else {
ctx.fillStyle = colorString(this.color, this.style); ctx.fillStyle = colorString(this.color);
ctx.fill(); ctx.fill();
} }