Created
December 14, 2012 15:44
-
-
Save bombless/4286354 to your computer and use it in GitHub Desktop.
Generate YUV color !!!
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
<!DOCTYPE html> | |
<html><body> | |
<script type="text/javascript"> | |
(function(){ | |
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 + ')'; | |
} | |
var Y, U, V, myColor, magic = 0, count = 0; | |
for(Y = 0; Y < 256; ++Y){ | |
for(U = 0; U < 256; ++U){ | |
for(V = 0; V < 256; ++V){ | |
// | |
if(magic++ <= 233 * 233? false: (magic = 0,true)){ | |
++count; | |
(function(div){ | |
div.style.width = '100%'; | |
div.style.height = '1px'; | |
myColor = genYUVColor( | |
65536 * Y + 256 * U + V | |
); | |
div.style.background = myColor; | |
div.style.color = myColor; | |
//div.innerHTML = div.style.color; | |
document.write('color ' + myColor + ';'); | |
document.body.appendChild(div); | |
})(document.createElement('div')); | |
} | |
} | |
} | |
} | |
document.write('count ' + count); | |
})(); | |
</script></body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment