From 1d5bf3bd758b921fbdc48c677eb2a2a16504ab0a Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 19 Jan 2022 16:06:34 +0100 Subject: [PATCH] [ts][canvas] Closes #2008, incorrect setting of global alpha. --- spine-ts/spine-canvas/src/SkeletonRenderer.ts | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/spine-ts/spine-canvas/src/SkeletonRenderer.ts b/spine-ts/spine-canvas/src/SkeletonRenderer.ts index 9cc2b72e2..787efe5a3 100644 --- a/spine-ts/spine-canvas/src/SkeletonRenderer.ts +++ b/spine-ts/spine-canvas/src/SkeletonRenderer.ts @@ -94,13 +94,7 @@ export class SkeletonRenderer { ctx.scale(1, -1); ctx.translate(-w / 2, -h / 2); - if (color.r != 1 || color.g != 1 || color.b != 1 || color.a != 1) { - ctx.globalAlpha = color.a; - // experimental tinting via compositing, doesn't work - // ctx.globalCompositeOperation = "source-atop"; - // ctx.fillStyle = "rgba(" + (color.r * 255 | 0) + ", " + (color.g * 255 | 0) + ", " + (color.b * 255 | 0) + ", " + color.a + ")"; - // ctx.fillRect(0, 0, w, h); - } + ctx.globalAlpha = color.a; ctx.drawImage(image, region.x, region.y, w, h, 0, 0, w, h); if (this.debugRendering) ctx.strokeRect(0, 0, w, h); ctx.restore(); @@ -147,13 +141,7 @@ export class SkeletonRenderer { skeletonColor.b * slotColor.b * attachmentColor.b, skeletonColor.a * slotColor.a * attachmentColor.a); - if (color.r != 1 || color.g != 1 || color.b != 1 || color.a != 1) { - ctx.globalAlpha = color.a; - // experimental tinting via compositing, doesn't work - // ctx.globalCompositeOperation = "source-atop"; - // ctx.fillStyle = "rgba(" + (color.r * 255 | 0) + ", " + (color.g * 255 | 0) + ", " + (color.b * 255 | 0) + ", " + color.a + ")"; - // ctx.fillRect(0, 0, w, h); - } + ctx.globalAlpha = color.a; for (var j = 0; j < triangles.length; j += 3) { let t1 = triangles[j] * 8, t2 = triangles[j + 1] * 8, t3 = triangles[j + 2] * 8;