Re: Making an interactive RGB color picker

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

 



On 3/3/08, Keikonium <Keikonium@xxxxxxxxxxx> wrote:
> This may not be exactly what you think, but I didn't know how else to word
> the title. I basically need to make a script that will go through every
> possible color combination and print them to look just like (or similar) to
> the windows color picker. I need it in the format X-Y-Z. For example:
>
> 255-255-255
> 255-254-254
> 255-253-253
>
> What I have so far is this:
>
> ***********************
> <?php
> $break = print"<br>";
> $n1 = "255";
> $n2 = "12";
> $n3 = "186";
>
> $output = print"
> \$drawrect(\$get(color_x),\$get(color_y),\$get(color_w),\$get(color_h),brushColor-$n1-$n2-$n3
> penColor-$n1-$n2-$n3)
> \$button2(\$get(color_x),\$get(color_y),0,0,\$get(color_w),\$get(color_h),,,PVAR:SET:colorize_global:brushcolor-$n1-$n2-$n3
> pencolor-$n1-$n2-$n3,TOOLTIP:\"$n1-$n2-$n3\")
> ";
>
> $output
> ?>
> ***********************
>
> The $drawrect, $button2, and $get are NOT php functions, but to be printed
> as actual text (which is why I have escaped them with the backslash).
> Anyways, I thought it would be easiest to separate each R-G-B value into its
> own variable ($n1, $n2, and $n3). That way I could just use some code
> (regex?) to cycle through the numbers 0 to 255.
>
> The HARD part (that I can't seem to even think of a way to make it possible)
> is to change JUST the G and B values while keeping the R value at 255. Then
> when the G and B values both hit 0, the R value is set to 254 and repeated
> until it also hits 0 with the other two. I think (?) that will do every
> possible color? I also need to print each string with the individual color
> output, and I don't know how to do that either.
>
> In short, I would like something that looks just like the windows color
> picker, and when each pixel of it is clicked, it will show me the R-G-B
> value in the format I would like.
>
> If anyone understands what I am after,and could help, that would be awesome!
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
HTML
<a href="color.php"><img src="colormap.png" ismap="ismap" /></a>
PHP color.php
list($coords) = array_keys($_GET);
$coords = explode(',', $coords); // Easier way...?
$im = imagecreatefrompng('colormap.png');
$color = imagepixelat($im, $coords[0], $coords[1]);
I wouldn't do it like this, though. I'd use Javascript.
--
-Casey

-- 
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