titanscssc::alter_color PHP Method

alter_color() protected method

helper function for adjust_color, change_color, and scale_color
protected alter_color ( $args, $fn )
    protected function alter_color($args, $fn)
    {
        $color = $this->assertColor($args[0]);
        foreach (array(1, 2, 3, 7) as $i) {
            if (!is_null($args[$i])) {
                $val = $this->assertNumber($args[$i]);
                $ii = $i == 7 ? 4 : $i;
                // alpha
                $color[$ii] = $this->{$fn}(isset($color[$ii]) ? $color[$ii] : 0, $val, $i);
            }
        }
        if (!is_null($args[4]) || !is_null($args[5]) || !is_null($args[6])) {
            $hsl = $this->toHSL($color[1], $color[2], $color[3]);
            foreach (array(4, 5, 6) as $i) {
                if (!is_null($args[$i])) {
                    $val = $this->assertNumber($args[$i]);
                    $hsl[$i - 3] = $this->{$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;
    }
titanscssc