Skip to content

Instantly share code, notes, and snippets.

@remy
Created March 23, 2012 13:25
Show Gist options
  • Save remy/2170599 to your computer and use it in GitHub Desktop.
Save remy/2170599 to your computer and use it in GitHub Desktop.
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