Created
October 4, 2011 06:41
-
-
Save bensonk/1261030 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<html> | |
<head> | |
<title>Color Tests</title> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$(function() { | |
// Do Awesome Things With Colors! | |
function makeColor(index) { | |
function color(i) { | |
// Wrap around using modulus | |
i = i % 1530; | |
// Calculate the value | |
var v; | |
if(i < 255) v = i; | |
else if(i < 765) v = 255; | |
else if(i < 1020) v = 255 - (i - 765); | |
else v = 0; | |
// Make it a zero-padded value | |
v = v.toString(16); | |
if(v.length == 1) return "0" + v; | |
else return v; | |
} | |
function red(i) { return color(i + 510); } | |
function green(i) { return color(i); } | |
function blue(i) { return color(i + 1020); } | |
return "#" + red(index) + green(index) + blue(index); | |
// return "#" + red(i).toString(16) + green(i).toString(16) + blue(i).toString(16); | |
} | |
var colorDiv = $("#colors"); | |
for(var i = 0; i < 1530*8; i+=25) { | |
colorDiv.append("<p style=\"color:" + makeColor(i) + "\">" + makeColor(i) + "</p>"); | |
} | |
}); | |
</script> | |
</head> | |
<body> | |
<h1>Color Tests</h1> | |
<div id="colors"> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment