Graph::MakeLinearGradient PHP Метод

MakeLinearGradient() приватный Метод

Creates a linear gradient element
private MakeLinearGradient ( $id, $colours )
    private function MakeLinearGradient($id, $colours)
    {
        $stops = '';
        $direction = 'v';
        if (in_array($colours[count($colours) - 1], array('h', 'v'))) {
            $direction = array_pop($colours);
        }
        $x2 = $direction == 'v' ? 0 : '100%';
        $y2 = $direction == 'h' ? 0 : '100%';
        $gradient = array('id' => $id, 'x1' => 0, 'x2' => $x2, 'y1' => 0, 'y2' => $y2);
        $col_mul = 100 / (count($colours) - 1);
        foreach ($colours as $pos => $colour) {
            @(list($colour, $opacity) = explode(':', $colour));
            $stop = array('offset' => round($pos * $col_mul) . '%', 'stop-color' => $colour);
            if (is_numeric($opacity)) {
                $stop['stop-opacity'] = $opacity;
            }
            $stops .= $this->Element('stop', $stop);
        }
        return $this->Element('linearGradient', $gradient, NULL, $stops);
    }