Re: [PHP] Making an interactive RGB color picker

2008-03-04 Thread tedd

At 4:42 PM -0500 3/3/08, Daniel Brown wrote:

On Mon, Mar 3, 2008 at 3:13 PM, Keikonium [EMAIL PROTECTED] 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:


It's also available to view here (but the demo is limited to save
my server from Yahoo! Slurps, Google grabs, etc.):
[Demo] http://www.pilotpig.net/code-library/colorpicker.php
[Source]
http://www.pilotpig.net/code-library/source.php?f=colorpicker.php



While people are giving demo's, check this out:

http://webbytedd.com/c/access-color/

The code is there, it's javascript.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Making an interactive RGB color picker

2008-03-04 Thread Daniel Brown
On Tue, Mar 4, 2008 at 10:44 AM, tedd [EMAIL PROTECTED] wrote:
  While people are giving demo's, check this out:

  http://webbytedd.com/c/access-color/

  The code is there, it's javascript.

Ooh, it's purdy and shiny and I like it.

-- 
/Dan

Daniel P. Brown
Senior Unix Geek
? while(1) { $me = $mind--; sleep(86400); } ?

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



Re: [PHP] Making an interactive RGB color picker

2008-03-04 Thread Jim Lucas

Along the lines of tedd, I will share this one.

http://www.colourlovers.com/blog/2008/01/16/free-advanced-dhtml-color-picker/

--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Making an interactive RGB color picker

2008-03-04 Thread Richard Lynch
for ($red = 0; $red  256; $red++){
  for ($green = 0; $green  256; $green++){
for ($blue = 0; $blue  256; $blue++){
  $output = EOC
\$drawrect(\$get...
EOC;
}
  }
}

On Mon, March 3, 2008 2:13 pm, Keikonium 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 = printbr;
 $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




-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Making an interactive RGB color picker

2008-03-04 Thread Casey
On 3/3/08, Keikonium [EMAIL PROTECTED] 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 = printbr;
 $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.phpimg 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



Re: [PHP] Making an interactive RGB color picker

2008-03-03 Thread Daniel Brown
On Mon, Mar 3, 2008 at 3:13 PM, Keikonium [EMAIL PROTECTED] 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
[snip!]

This is a very Bad Idea[tm], because it's going to generate
16,777,216 lines that the browser needs to receive, parse, and
display.  This is going to be over 2,516,582,400 bytes (yes, 2.5GB!)
of data to be served.  There are several better ways of doing it,
including using an HTML image map that has all of the colors laid-out
by pixel coordinates, reducing the number of colors you want to
display, using Flash, or any number of alternatives.

In any case, here's the code:
?php
if($_GET['r']  $_GET['g']  $_GET['b']) {
if(
!preg_match('/^[0-9]{1,3}$/',$_GET['r'])
|| !preg_match('/^[0-9]{1,3}$/',$_GET['g'])
|| !preg_match('/^[0-9]{1,3}$/',$_GET['b'])
) {
die('Incorrect parameters specified.  Please try again.');
} else {
echo You chose the following:\n;
echo bR/b: .$_GET['r'].br /\n;
echo bG/b: .$_GET['g'].br /\n;
echo bB/b: .$_GET['b'].br /\n;
echo br /\n;
}
}

$newline = 63;

for($i=255;$i0;$i--) {
for($j=255;$j0;$j--) {
for($k=255;$k0;$k--) {
echo span
style=\background:rgb(.$i.,.$j.,.$k.);padding:0px;height=5px;width=5px;\;
echo a href=\?r=.$i.g=.$j.b=.$k.\;
echo 
style=\color:rgb(.$i.,.$j.,.$k.);\X/a/span;
if($newline === 0) {
echo br /\n;
$newline = 63;
} else {
echo \n;
$newline--;
}
}
}
}
?

It's also available to view here (but the demo is limited to save
my server from Yahoo! Slurps, Google grabs, etc.):
[Demo] http://www.pilotpig.net/code-library/colorpicker.php
[Source]
http://www.pilotpig.net/code-library/source.php?f=colorpicker.php
-- 
/Dan

Daniel P. Brown
Senior Unix Geek
? while(1) { $me = $mind--; sleep(86400); } ?

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