Forum Moderators: coopster
What I'm trying to do is come up with a script which will, if you will, combine two colors to a certain degree. For instance, let's say I have the colors red and blue, and I want to make purple. The degree would be 50% and the script would combine the two colors so that there is 50% of red and 50% of blue, resulting in purple.
How would I go about doing this?
Thanks,
Philip
function twol($num)
{
if(strlen($num) == 1)
{
return "0".$num;
}
else
{
return $num;
}
}function combine($from, $to, $degr)
{$sum=array(
(hexdec($from[0])*((100-$degr)/100))+(hexdec($to[0])*($degr/100)),
(hexdec($from[1])*((100-$degr)/100))+(hexdec($to[1])*($degr/100)),
(hexdec($from[2])*((100-$degr)/100))+(hexdec($to[2])*($degr/100)));
return twol(dechex($sum[0])).twol(dechex($sum[1])).twol(dechex($sum[2]));
}
combine(array("FF","00","00"), array("00","00","FF"), 50)