Re: Font color

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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\">&nbsp;</td>\n");
				print("<td width=\"100\" height=\"20\" 
bgcolor=\"#$hexoppcolor\">&nbsp;</td>\n");
				print("<td align=\"left\">#$hexoppcolor</td>\n");
				print("</tr>\n");
			}
		}
	}
	print("</table>\n");
?>
</body>
</html>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux