|
Posted by trlists on 04/16/05 07:14
Here is a little code that shows the "web-safe" colors and their
"opposites" using the algorithm I described in the previous message:
<html>
<head>
<title Web-safe color 'opposites'>
</head>
<body>
<?php
# Display color opposites for web colors
$weblist = array('00', '33', '66', '99', 'CC', 'FF');
print("<table cols=\"4\" cellspacing=\"5\" cellpadding=\"0\">");
print("<tr>\n");
print("<th align=\"right\">Color</td>\n");
print("<th width=\"100\" align=\"center\">Color swatch</td>\n");
print("<th width=\"100\" align=\"center\">'Opposite' swatch</td>\n");
print("<th align=\"left\">'Opposite' color</td>\n");
print("</tr>\n");
foreach ($weblist as $red) {
foreach ($weblist as $green) {
foreach ($weblist as $blue) {
$hexcolor = $red . $green . $blue;
$hexoppcolor = sprintf("%06X", (hexdec($hexcolor) ^ 0xFFFFFF));
print("<tr>\n");
print("<td align=\"right\">#$hexcolor</td>\n");
print("<td width=\"100\" height=\"20\"
bgcolor=\"#$hexcolor\"> </td>\n");
print("<td width=\"100\" height=\"20\"
bgcolor=\"#$hexoppcolor\"> </td>\n");
print("<td align=\"left\">#$hexoppcolor</td>\n");
print("</tr>\n");
}
}
}
print("</table>\n");
?>
</body>
</html>
[Back to original message]
|