Created
March 23, 2012 13:25
-
-
Save remy/2170599 to your computer and use it in GitHub Desktop.
This file contains 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
var source = [255,128,0]; // orange-ish | |
// get pixels from canvas | |
for (i = 0; i < pixels.data.length; i += 4) { | |
brightness = ((3*pixels.data[i]+4*pixels.data[i+1]+pixels.data[i+2])>>>3) / 256; | |
pixels.data[i] = ((source[0] * brightness)+0.5)>>0; | |
pixels.data[i+1] = ((source[1] * brightness)+0.5)>>0 | |
pixels.data[i+2] = ((source[2] * brightness)+0.5)>>0 | |
} | |
// pixels now tinted to orange |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment