On Tue, 2009-05-12 at 18:05 +0300, Thodoris wrote:
>
> Still curious about the right script though (if this is possible of
> course).
Of course it's possible... but you're probably not going to get the
results you want since you're taking 3 dimensions and trying to push
them into 2. You'll notice most colour pickers have a square for a given
colour, and a bar to pick the colour. The following will produce a
colour picker, but it won't look like what you expect:
<?php
$width = $height = 500;
$im = imagecreatetruecolor( $width, $height );
$root = pow( $width * $height, 1/3 );
$x = $y = 0;
for( $r = 0; $r < $root; $r++ )
{
$rv = (int)(256 * ($r / $root));
for( $g = 0; $g < $root; $g++ )
{
$gv = (int)(256 * ($g / $root));
for( $b = 0; $b < $root; $b++ )
{
$bv = (int)(256 * ($b / $root));
$n = imagecolorallocate( $im, $rv, $gv, $bv );
imagesetpixel( $im, $x, $y, $n );
if( ++$x >= $width )
{
$x = 0;
$y++;
}
}
}
}
header( "Content-Type: image/png" );
imagepng( $im );
imagedestroy( $im );
?>
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php