protected function alterColor($args, $fn)
{
$color = $this->assertColor($args[0]);
foreach ([1, 2, 3, 7] as $i) {
if (isset($args[$i])) {
$val = $this->assertNumber($args[$i]);
$ii = $i === 7 ? 4 : $i;
// alpha
$color[$ii] = call_user_func($fn, isset($color[$ii]) ? $color[$ii] : 0, $val, $i);
}
}
if (isset($args[4]) || isset($args[5]) || isset($args[6])) {
$hsl = $this->toHSL($color[1], $color[2], $color[3]);
foreach ([4, 5, 6] as $i) {
if (isset($args[$i])) {
$val = $this->assertNumber($args[$i]);
$hsl[$i - 3] = call_user_func($fn, $hsl[$i - 3], $val, $i);
}
}
$rgb = $this->toRGB($hsl[1], $hsl[2], $hsl[3]);
if (isset($color[4])) {
$rgb[4] = $color[4];
}
$color = $rgb;
}
return $color;
}