[ts][canvas] Fixed alpha tinting

This commit is contained in:
badlogic 2017-03-02 11:50:46 +01:00
parent d5cc4d598a
commit 7e0df8fa6d
3 changed files with 3 additions and 3 deletions

View File

@ -260,10 +260,10 @@ var spine;
ctx.translate(w / 2, h / 2); ctx.translate(w / 2, h / 2);
ctx.scale(1, -1); ctx.scale(1, -1);
ctx.translate(-w / 2, -h / 2); ctx.translate(-w / 2, -h / 2);
ctx.drawImage(image, region.x, region.y, w, h, 0, 0, w, h);
if (color.r != 1 || color.g != 1 || color.b != 1 || color.a != 1) { if (color.r != 1 || color.g != 1 || color.b != 1 || color.a != 1) {
ctx.globalAlpha = color.a; ctx.globalAlpha = color.a;
} }
ctx.drawImage(image, region.x, region.y, w, h, 0, 0, w, h);
if (this.debugRendering) if (this.debugRendering)
ctx.strokeRect(0, 0, w, h); ctx.strokeRect(0, 0, w, h);
ctx.restore(); ctx.restore();

File diff suppressed because one or more lines are too long

View File

@ -90,7 +90,6 @@ module spine.canvas {
ctx.translate(w / 2, h / 2); ctx.translate(w / 2, h / 2);
ctx.scale(1, -1); ctx.scale(1, -1);
ctx.translate(-w / 2, -h / 2); ctx.translate(-w / 2, -h / 2);
ctx.drawImage(image, region.x, region.y, w, h, 0, 0, w, h);
if (color.r != 1 || color.g != 1 || color.b != 1 || color.a != 1) { if (color.r != 1 || color.g != 1 || color.b != 1 || color.a != 1) {
ctx.globalAlpha = color.a; ctx.globalAlpha = color.a;
// experimental tinting via compositing, doesn't work // experimental tinting via compositing, doesn't work
@ -98,6 +97,7 @@ module spine.canvas {
// ctx.fillStyle = "rgba(" + (color.r * 255 | 0) + ", " + (color.g * 255 | 0) + ", " + (color.b * 255 | 0) + ", " + color.a + ")"; // ctx.fillStyle = "rgba(" + (color.r * 255 | 0) + ", " + (color.g * 255 | 0) + ", " + (color.b * 255 | 0) + ", " + color.a + ")";
// ctx.fillRect(0, 0, w, h); // ctx.fillRect(0, 0, w, h);
} }
ctx.drawImage(image, region.x, region.y, w, h, 0, 0, w, h);
if (this.debugRendering) ctx.strokeRect(0, 0, w, h); if (this.debugRendering) ctx.strokeRect(0, 0, w, h);
ctx.restore(); ctx.restore();
} }