Skip to content

Instantly share code, notes, and snippets.

@ayamflow
Last active September 20, 2017 18:12
Show Gist options
  • Save ayamflow/c82dda73c804c4d3bdd657f907f0be81 to your computer and use it in GitHub Desktop.
Save ayamflow/c82dda73c804c4d3bdd657f907f0be81 to your computer and use it in GitHub Desktop.
Canvas multiply (IE)
// Also see https://github.com/Phrogz/context-blender
function multiply(R, G, B) {
var imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);
var data = imgData.data;
for (var i = 0; i < data.length; i += 4) {
data[i ] = R * data[i ] / 255;
data[i + 1] = G * data[i + 1] / 255;
data[i + 2] = B * data[i + 2] / 255;
}
ctx.putImageData(imgData, 0, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment