| OLD | NEW |
| 1 var blendModes = ["source-over", "multiply", "screen", "overlay", "darken", "lig
hten", "color-dodge", "color-burn", | 1 var blendModes = ["source-over", "multiply", "screen", "overlay", "darken", "lig
hten", "color-dodge", "color-burn", |
| 2 "hard-light", "soft-light", "difference", "exclusion", "hue",
"saturation", "color", "luminosity"]; | 2 "hard-light", "soft-light", "difference", "exclusion", "hue",
"saturation", "color", "luminosity"]; |
| 3 | 3 |
| 4 // Helper functions for separate blend mode | 4 // Helper functions for separate blend mode |
| 5 | 5 |
| 6 var separateBlendmodes = ["normal", "multiply", "screen", "overlay", | 6 var separateBlendmodes = ["normal", "multiply", "screen", "overlay", |
| 7 "darken", "lighten", "colorDodge","colorBurn", | 7 "darken", "lighten", "colorDodge","colorBurn", |
| 8 "hardLight", "softLight", "difference", "exclusion"]; | 8 "hardLight", "softLight", "difference", "exclusion"]; |
| 9 | 9 |
| 10 var separateBlendFunctions = { | 10 var separateBlendFunctions = { |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 return applyBlendMode(backdrop, source, separateBlendFunctions[separateBlend
modes[blendModeIndex]]); | 294 return applyBlendMode(backdrop, source, separateBlendFunctions[separateBlend
modes[blendModeIndex]]); |
| 295 } | 295 } |
| 296 | 296 |
| 297 function nonSeparateBlendColors(backdrop, source, blendModeIndex) { | 297 function nonSeparateBlendColors(backdrop, source, blendModeIndex) { |
| 298 var expectedColor = nonSeparateBlendFunctions[nonSeparateBlendModes[blendMod
eIndex]](backdrop, source); | 298 var expectedColor = nonSeparateBlendFunctions[nonSeparateBlendModes[blendMod
eIndex]](backdrop, source); |
| 299 for (var i = 0; i < 3; ++i) | 299 for (var i = 0; i < 3; ++i) |
| 300 expectedColor[i] = source[3] * (1 - backdrop[3]) * source[i] + source[3]
* backdrop[3] * expectedColor[i] + (1 - source[3]) * backdrop[3] * backdrop[i]; | 300 expectedColor[i] = source[3] * (1 - backdrop[3]) * source[i] + source[3]
* backdrop[3] * expectedColor[i] + (1 - source[3]) * backdrop[3] * backdrop[i]; |
| 301 return [Math.round(255 * expectedColor[0]), Math.round(255 * expectedColor[1
]), Math.round(255 * expectedColor[2]), 255]; | 301 return [Math.round(255 * expectedColor[0]), Math.round(255 * expectedColor[1
]), Math.round(255 * expectedColor[2]), 255]; |
| 302 } | 302 } |
| 303 | 303 |
| 304 function checkBlendModeResult(i, context, sigma) { | 304 function checkBlendModeResult(i, context, sigma, x, y) { |
| 305 var actualColor = context.getImageData(0, 0, 1, 1).data; | 305 if (x === undefined) |
| 306 x = 0; |
| 307 if (y === undefined) |
| 308 y = 0; |
| 309 var actualColor = context.getImageData(x, y, 1, 1).data; |
| 306 var expectedColor = blendColors([129 / 255, 1, 129 / 255, 1], [1, 129 / 255,
129 / 255, 1], i); | 310 var expectedColor = blendColors([129 / 255, 1, 129 / 255, 1], [1, 129 / 255,
129 / 255, 1], i); |
| 307 assert_approx_equals(actualColor[0], expectedColor[0], sigma); | 311 assert_approx_equals(actualColor[0], expectedColor[0], sigma); |
| 308 assert_approx_equals(actualColor[1], expectedColor[1], sigma); | 312 assert_approx_equals(actualColor[1], expectedColor[1], sigma); |
| 309 assert_approx_equals(actualColor[2], expectedColor[2], sigma); | 313 assert_approx_equals(actualColor[2], expectedColor[2], sigma); |
| 310 assert_approx_equals(actualColor[3], expectedColor[3], sigma); | 314 assert_approx_equals(actualColor[3], expectedColor[3], sigma); |
| 311 } | 315 } |
| OLD | NEW |