Graphics
|
|
|
|
<font size="1"><b><PRE STYLE="font-size: 6pt;line-height: 6pt;">
<!-- color table crap -->
<script language=JavaScript>
<!-- Begin
function showColor2(val) {
document.bgColor = val;
document.test.background.value = val;
}
// End -->
</script>
<?
$MODIFIER = 3;
function RGB_to_HEX($r, $g, $b) {
// r
$red = dechex($r);
if(!isset($red[1])) { $red = "0".$red; }
// g
$green = dechex($g);
if(!isset($green[1])) { $green = "0".$green; }
// b
$blue = dechex($b);
if(!isset($blue[1])) { $blue = "0".$blue; }
return "#".$red.$green.$blue;
}
if(!$file) $file = "colorwheel2.jpg"; $image = imagecreatefromjpeg($file); $width = imagesx($image); $height = imagesy($image);
unset($text); $text[0] = "#"; $y=1; while($y<$height) {
$x=1; while($x<$width) {
$index = imagecolorat($image, $x, $y);
$array = imagecolorsforindex($image, $index);
$color = RGB_TO_HEX($array["red"],$array["green"],$array["blue"]);
if(!isset($text[$i])) $i=0;
$map .= "<area shape=RECT coords=$x,$y,".($x+$MODIFIER).",". ($y+$MODIFIER)." href="javascript:showColor2('$color')">n";
$lastcolor = $color;
$x=$x+$MODIFIER; $i++;
}
$y=$y+$MODIFIER;
} ?> <img src="colorwheel2.jpg" usemap=#colmap2 border=0>
<map name=colmap2>
<? echo $map ?> </map>
<br><form name=test><input SIZE=8 VALUE=FFFFFF NAME=background CLASS="Input"></form>
</font></pre></b></font>
|
|
|
Usage Example
|
|
|
Rate This Script
|
|
|
|