Skip to content

Instantly share code, notes, and snippets.

@guilhermehn
Created April 15, 2014 03:09
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 guilhermehn/10698899 to your computer and use it in GitHub Desktop.
Save guilhermehn/10698899 to your computer and use it in GitHub Desktop.
function getRgba (ctx, x, y) {
var colors = ['r', 'g', 'b', 'a']
, result = {}
, data = ctx.getImageData(x, y, 1, 1)
data.forEach(function (c, i) {
result[colors[i]] = c
})
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment