From 4a9f0d726f1e48b230033b5a2532f9a9618c389d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Wed, 1 Jun 2011 14:00:02 +0100 Subject: [PATCH] Pre-calculate opacity value. --- src/util/BlendMode.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/BlendMode.js b/src/util/BlendMode.js index 8138bb31..4f0300c3 100644 --- a/src/util/BlendMode.js +++ b/src/util/BlendMode.js @@ -53,6 +53,7 @@ var BlendMode = { dst = dstD.data, min = Math.min, sA, dA, dA2, sRA, sGA, sBA, dRA, dGA, dBA, demultiply; + opacity = opacity / 255, // TODO: Some blend modes seem broken at the moment, e.g. // dodge, burn @@ -162,7 +163,7 @@ var BlendMode = { var process = modes[blendMode] || modes.unsupported; for (var i = 0, l = dst.length; i < l; i += 4) { - sA = src[i + 3] / 255 * opacity; + sA = src[i + 3] * opacity; dA = dst[i + 3] / 255; dA2 = sA + dA - sA * dA; sRA = src[i] / 255 * sA;