Skip to content

Instantly share code, notes, and snippets.

@mikemorris
Created August 13, 2012 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikemorris/3342111 to your computer and use it in GitHub Desktop.
Save mikemorris/3342111 to your computer and use it in GitHub Desktop.
Canvas pixel map technique from Paul Bakaus' Google Talk http://www.youtube.com/watch?v=_RRnyChxijA&feature=related
var clickMap = [];
for (var i = 0; n = imageData.length; i < n; i += 4) {
var row = Math.floor((i/4) / width);
var col = (i/4) - (row * width);
if(!clickMap[row]) clickMap[row] = [];
clickMap[row][col] = imageData[i+3] == 0 ? 0 : 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment