protected function libMix($args)
{
list($first, $second, $weight) = $args;
$first = $this->assertColor($first);
$second = $this->assertColor($second);
if (!isset($weight)) {
$weight = 0.5;
} else {
$weight = $this->coercePercent($weight);
}
$firstAlpha = isset($first[4]) ? $first[4] : 1;
$secondAlpha = isset($second[4]) ? $second[4] : 1;
$w = $weight * 2 - 1;
$a = $firstAlpha - $secondAlpha;
$w1 = (($w * $a === -1 ? $w : ($w + $a) / (1 + $w * $a)) + 1) / 2.0;
$w2 = 1.0 - $w1;
$new = [Type::T_COLOR, $w1 * $first[1] + $w2 * $second[1], $w1 * $first[2] + $w2 * $second[2], $w1 * $first[3] + $w2 * $second[3]];
if ($firstAlpha != 1.0 || $secondAlpha != 1.0) {
$new[] = $firstAlpha * $weight + $secondAlpha * ($weight - 1);
}
return $this->fixColor($new);
}