public static function mix($color1, $color2, $weight) 
    {
        if ($weight < 0) {
            $weight = 0;
        } elseif ($weight > 1) {
            $weight = 1;
        }
        
        $a = ($color1 & 0xff) * (1 - $weight) + ($color2 & 0xff) * $weight;
        if ($a <= 0.1) {
            return 0;
        }
        
        $r = (
            ($color1 >> 24) * ($color1 & 0xff) * (1 - $weight) +
            ($color2 >> 24) * ($color2 & 0xff) * $weight
            ) / $a;
            
        $g = (
            (($color1 >> 16) & 0xff) * ($color1 & 0xff) * (1 - $weight) +
            (($color2 >> 16) & 0xff) * ($color2 & 0xff) * $weight
            ) / $a;
            
        $b = (
            (($color1 >> 8) & 0xff) * ($color1 & 0xff) * (1 - $weight) +
            (($color2 >> 8) & 0xff) * ($color2 & 0xff) * $weight
            ) / $a;
        
        if ($a > 255) $a = 255;    
        if ($r > 255) $r = 255;
        if ($g > 255) $g = 255;
        if ($b > 255) $b = 255;
        
        return ((int)$r << 24) | ((int)$g << 16) | ((int)$b << 8) | (int)$a;
    }
public static function mix($color1, $color2, $weight) 
    {
        if ($weight < 0) {
            $weight = 0;
        } elseif ($weight > 1) {
            $weight = 1;
        }
        
        $a = ($color1 & 0xff) * (1 - $weight) + ($color2 & 0xff) * $weight;
        if ($a <= 0.1) {
            return 0;
        }
        
        $r = (
            ($color1 >> 24) * ($color1 & 0xff) * (1 - $weight) +
            ($color2 >> 24) * ($color2 & 0xff) * $weight
            ) / $a;
            
        $g = (
            (($color1 >> 16) & 0xff) * ($color1 & 0xff) * (1 - $weight) +
            (($color2 >> 16) & 0xff) * ($color2 & 0xff) * $weight
            ) / $a;
            
        $b = (
            (($color1 >> 8) & 0xff) * ($color1 & 0xff) * (1 - $weight) +
            (($color2 >> 8) & 0xff) * ($color2 & 0xff) * $weight
            ) / $a;
        
        if ($a > 255) $a = 255;    
        if ($r > 255) $r = 255;
        if ($g > 255) $g = 255;
        if ($b > 255) $b = 255;
        
        return ((int)$r << 24) | ((int)$g << 16) | ((int)$b << 8) | (int)$a;
    }
public static function mix ( $ color1 , $ color2 , $ weight ) { if ( $ weight < 0 ) { $ weight = 0 ; } elseif ( $ weight > 1 ) { $ weight = 1 ; } $ a = ( $ color1 & 0xff ) * ( 1 - $ weight ) + ( $ color2 & 0xff ) * $ weight ; if ( $ a <= 0.1 ) { return 0 ; } $ r = ( ( $ color1 >> 24 ) * ( $ color1 & 0xff ) * ( 1 - $ weight ) + ( $ color2 >> 24 ) * ( $ color2 & 0xff ) * $ weight ) / $ a ; $ g = ( ( ( $ color1 >> 16 ) & 0xff ) * ( $ color1 & 0xff ) * ( 1 - $ weight ) + ( ( $ color2 >> 16 ) & 0xff ) * ( $ color2 & 0xff ) * $ weight ) / $ a ; $ b = ( ( ( $ color1 >> 8 ) & 0xff ) * ( $ color1 & 0xff ) * ( 1 - $ weight ) + ( ( $ color2 >> 8 ) & 0xff ) * ( $ color2 & 0xff ) * $ weight ) / $ a ; if ( $ a > 255 ) $ a = 255 ; if ( $ r > 255 ) $ r = 255 ; if ( $ g > 255 ) $ g = 255 ; if ( $ b > 255 ) $ b = 255 ; return ( ( int ) $ r << 24 ) | ( ( int ) $ g << 16 ) | ( ( int ) $ b << 8 ) | ( int ) $ a ; }
Computes a mix of the two specified colors, with the proportion given
by the specified weight.

@param integer $color1  First color to mix.
@param integer $color2  Second color to mix.
@param float $weight  Weight in the range [0,1].
0 gives $color1, 1 gives $color2.
@return integer Mixed color.
Computes a mix of the two specified colors with the proportion given by the specified weight .