Horde_Image_Imagick::arc PHP Méthode

arc() public méthode

Draws an arc.
public arc ( integer $x, integer $y, integer $r, integer $start, integer $end, string $color = 'black', string $fill = 'none' )
$x integer The x coordinate of the centre.
$y integer The y coordinate of the centre.
$r integer The radius of the arc.
$start integer The start angle of the arc.
$end integer The end angle of the arc.
$color string The line color of the arc.
$fill string The fill color of the arc (defaults to none).
    public function arc($x, $y, $r, $start, $end, $color = 'black', $fill = 'none')
    {
        $points = Horde_Image::arcPoints($r, $start, $end);
        $points['x1'] += $x;
        $points['x2'] += $x;
        $points['x3'] += $x;
        $points['y1'] += $y;
        $points['y2'] += $y;
        $points['y3'] += $y;
        try {
            $draw = new ImagickDraw();
            $draw->setStrokeColor(new ImagickPixel($color));
            $draw->setFillColor(new ImagickPixel($fill));
            $draw->arc($x - $r, $y - $r, $x + $r, $y + $r, $start, $end);
        } catch (ImagickDrawException $e) {
            throw new Horde_Image_Exception($e);
        } catch (ImagickPixelException $e) {
            throw new Horde_Image_Exception($e);
        }
        // If filled, draw the outline.
        if (!empty($fill)) {
            $mid = round(($start + $end) / 2);
            list($x1, $y1) = Horde_Image::circlePoint($start, $r * 2);
            list($x2, $y2) = Horde_Image::circlePoint($mid, $r * 2);
            list($x3, $y3) = Horde_Image::circlePoint($end, $r * 2);
            $verts = array(array('x' => $x + round($x3), 'y' => $y + round($y3)), array('x' => $x, 'y' => $y), array('x' => $x + round($x1), 'y' => $y + round($y1)));
            if ($mid > 90) {
                $verts1 = array(array('x' => $x + round($x2), 'y' => $y + round($y2)), array('x' => $x, 'y' => $y), array('x' => $x + round($x1), 'y' => $y + round($y1)));
                $verts2 = array(array('x' => $x + round($x3), 'y' => $y + round($y3)), array('x' => $x, 'y' => $y), array('x' => $x + round($x2), 'y' => $y + round($y2)));
                $this->polygon($verts1, $fill, $fill);
                $this->polygon($verts2, $fill, $fill);
            } else {
                $this->polygon($verts, $fill, $fill);
            }
            $this->polyline($verts, $color);
        }
        try {
            $this->_imagick->drawImage($draw);
        } catch (ImagickException $e) {
            throw new Horde_Image_Exception($e);
        }
        $draw->destroy();
    }