Two glaring typos were fixed
Chris wrote:
Well I would suggest you find some PHP code That converts between
HSB/HSL (Hue-Saturation-Brightness/Lightness). From there are are a
multitude of fairly simple algorithms that will give you complementary
colors. You can find these by searching on "Complimentary Colors",
"Color Wheel", "Adjacent Colors" to name a few.
That converts between HSB/HSL (Hue-Saturation-Brightness/Lightness) *
and RGB*
This has the added bonus that you can restrict the brightness of a
color by the brightness itself, not arbirtrailly disallowing any of
the 3 RGB values to be below a certain point.
Here is a bit of code that would generate a random color, above a
specified brightness, and also give you it's complimentary colors. It
assumes a Hue value 0-359 , as opposed to some which are used on a
0-99 scale.
<?php
$iMinB = 62; // This represents a percentage
$iH = rand(0,359); // Generate random Hue
$fS = rand(3000,7000)/10000; // Generate Random Float between 0.3 and 0.7
$fB = rand($iMinB*100,10000)/10000; // Generate Random Float between
0.62 and 1.0
/* Now, the complimentary colors will have the same Saturation and
Brightness, jsut different hue values, rotate 120 degrees apart */
$iComp1H = ($iH+120)%360;
$iComp2H = ($iComp1H+120)%360;
echo ' Hue: ',$iH,"\n";
echo 'Comp 1 Hue: ',$iComp1H,"\n";
echo 'Comp 2 Hue: ',$iComp2H,"\n";
echo 'Saturation: ',$fS,"\n";
echo 'Brightness: ',$fB,"\n";
?>
This is hastily put together, but it's the sort of thing that would
definitely work, and, in my opinion, works best. You'll just need
something to convert HSB to RGB, to get the color in a form GD
understands.
One alternative, with HSB, is to generate random RGB values, then just
rotate them through (RGB = Primary color, GBR = Color 1, GRB = Color 2)
*without* HSB
This generally produces pretty color patterns.
Chris
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php