PHP Code:
$hex = array("00", "33", "66", "99", "CC", "FF");
echo "Web Safe Color Chart
";
echo ""
;
for ($r=0; $r<count($hex); $r++){ //the red colors loop
for ($g=0; $g<count($hex); $g++){ //the green colors loop
echo ""; //Define a row for the six blue colors
for ($b=0; $b<count($hex); $b++){ //iterate through the six blue colors
$color = $hex[$r].$hex[$g].$hex[$b];
//At this point we decide what font color to use
if ( $hex[$r] <= "99" && $hex[$g] <= "99" && $hex[$b] <= "99"){
// Use a white font if the color is going to be fairly dark
echo " .$col."'> ".$col." ";
} else {
// Use a black font on the lighter colors
echo " .$col."'> ".$col." ";
}
} //End of b-blue innermost loop
echo "\n\r"; // close row after writing six color cells
} //End of g-green loop } //End of r-red outermost loop ?>
No comments:
Post a Comment