Making an interactive RGB color picker

From: Date: Mon, 03 Mar 2008 20:13:55 +0000
Subject: Making an interactive RGB color picker
Groups: php.general 
Request: Send a blank email to php-general+get-270875@lists.php.net to get a copy of this message
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!

« previous php.general (#270875) next »