Skip to content

Instantly share code, notes, and snippets.

@Layzie
Created July 20, 2012 11:13
Show Gist options
  • Save Layzie/3150211 to your computer and use it in GitHub Desktop.
Save Layzie/3150211 to your computer and use it in GitHub Desktop.
Make image to white using canvas(enchant.js)
machine1Canvas.draw(game.assets['./images/mc_01.png']);
var oldImg = machine1Canvas.clone();
machine1_old.image = oldImg;
var imgData = machine1Canvas.context.getImageData(0, 0, 742, 498);
oldImgData = imgData;
function setWhite() {
for (var i = 0; i < 369516 * 4; i += 4) {
imgData.data[i] = 255;
imgData.data[i + 1] = 255;
imgData.data[i + 2] = 255;
}
machine1Canvas.context.putImageData(imgData, 0, 0);
}
setWhite();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment