Here's the code in case anyone's interested:
<?php
$output_hex = "";
if (isset($_GET['hex1']) && isset($_GET['hex2'])) {
$hex1 = str_replace("#", "", $_GET['hex1']);
$hex2 = str_replace("#", "", $_GET['hex2']);
$rgb1 = array();
$rgb2 = array();
$rgb1[0] = hexdec(substr($hex1, 0, 2));
$rgb1[1] = hexdec(substr($hex1, 2, 2));
$rgb1[2] = hexdec(substr($hex1, 4, 2));
$rgb2[0] = hexdec(substr($hex2, 0, 2));
$rgb2[1] = hexdec(substr($hex2, 2, 2));
$rgb2[2] = hexdec(substr($hex2, 4));
$finish = array();
$finish[0] = ($rgb1[0] + $rgb2[0]) / 2;
$finish[1] = ($rgb1[1] + $rgb2[1]) / 2;
$finish[2] = ($rgb1[2] + $rgb2[2]) / 2;
$output_hex = "";
for ($i = 0; $i < 3; $i++) {
if ($finish[$i] == 0) {
$output_hex .= "00";
} else {
$output_hex .= dechex($finish[$i]);
}
}
}
?>
<html>
<title>Combine Codes</title>
<body>
<?php
if (isset($_GET['hex1']) && isset($_GET['hex2'])) {
echo "Combined Hex: " . $output_hex . "<br />";
echo "<table><tr><th>Color 1</th><th>Combined Color</th><th>Color 2</th></tr>";
echo "<tr>";
echo "<td style='width: 200px; height: 75px; background-color: " . $_GET['hex1'] . ";'> </td>";
echo "<td style='width: 200px; height: 75px; background-color: " . $output_hex . ";'> </td>";
echo "<td style='width: 200px; height: 75px; background-color: " . $_GET['hex2'] . ";'> </td>";
echo "</tr>";
echo "</table>";
}
?>
<form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
Color Code 1: <input type="text" name="hex1" size="7" maxlength="7"><br />
Color Code 2: <input type="text" name="hex2" size="7" maxlength="7"><br />
<input type="submit" value="Get Mixed Code">
</form>
</body>
</html>

New Topic/Question
Reply


MultiQuote




|