Created
April 27, 2014 12:44
-
-
Save z-------------/11344689 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getPixelColor(x,y,canvas){ // where canvas is an HTMLCanvasElement | |
| var ctx = canvas.getContext("2d"); | |
| var idata = ctx.getImageData(0,0,canvas.width,canvas.height); | |
| var p = ((y*(idata.width*4)) + (x*4)); | |
| var d = idata.data; | |
| return [d[p],d[p+1],d[p+2]]; // returns an array of that pixel's red, green and blue values | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment