Skip to content

Instantly share code, notes, and snippets.

@bombless
Created December 14, 2012 15:53
Show Gist options
  • Save bombless/4286412 to your computer and use it in GitHub Desktop.
Save bombless/4286412 to your computer and use it in GitHub Desktop.
genYUVColor()
function genYUVColor(input){
var Y,U,V;
var R,G,B;
Y = Math.floor(input / 65536);
U = Math.floor(input % 65536 / 256);
V = Math.floor(input % 256);
document.write('<div>YUV(' + Y + ',' + U + ',' + V + ')</div>');
R = Math.floor(Y + 1.14 * V);
G = Math.floor(Y - 0.39 * U - 0.58 * V);
B = Math.floor(Y + 2.03 * U);
return 'rgb(' + R + ',' + G + ',' + B + ')';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment