Pop\Pdf\Pdf::drawArc PHP Method

drawArc() public method

Method to add an arc to the PDF.
public drawArc ( integer $x, integer $y, integer $start, integer $end, integer $w, integer $h = null, boolean $fill = true ) : Pdf
$x integer
$y integer
$start integer
$end integer
$w integer
$h integer
$fill boolean
return Pdf
    public function drawArc($x, $y, $start, $end, $w, $h = null, $fill = true)
    {
        if (null === $h) {
            $h = $w;
        }
        $sX = round($w * cos($start / 180 * pi()));
        $sY = round($h * sin($start / 180 * pi()));
        $eX = round($w * cos($end / 180 * pi()));
        $eY = round($h * sin($end / 180 * pi()));
        $centerPoint = array('x' => $x, 'y' => $y);
        $startPoint = array('x' => $x + $sX, 'y' => $y - $sY);
        $endPoint = array('x' => $x + $eX, 'y' => $y - $eY);
        $startQuad = $this->getQuadrant($startPoint, $centerPoint);
        $endQuad = $this->getQuadrant($endPoint, $centerPoint);
        $maskPoint1 = array('x' => $x + $w + 50, 'y' => $y - $h - 50);
        $maskPoint2 = array('x' => $x - $w - 50, 'y' => $y - $h - 50);
        $maskPoint3 = array('x' => $x - $w - 50, 'y' => $y + $h + 50);
        $maskPoint4 = array('x' => $x + $w + 50, 'y' => $y + $h + 50);
        $polyPoints = array($centerPoint, $startPoint);
        switch ($startQuad) {
            case 1:
                $polyPoints[] = $maskPoint1;
                if ($endQuad == 1) {
                    $polyPoints[] = $maskPoint4;
                    $polyPoints[] = $maskPoint3;
                    $polyPoints[] = $maskPoint2;
                    $polyPoints[] = array('x' => $endPoint['x'], 'y' => $maskPoint2['y']);
                } else {
                    if ($endQuad == 2) {
                        $polyPoints[] = $maskPoint4;
                        $polyPoints[] = $maskPoint3;
                        $polyPoints[] = $maskPoint2;
                    } else {
                        if ($endQuad == 3) {
                            $polyPoints[] = $maskPoint4;
                            $polyPoints[] = $maskPoint3;
                        } else {
                            if ($endQuad == 4) {
                                $polyPoints[] = $maskPoint4;
                            }
                        }
                    }
                }
                break;
            case 2:
                $polyPoints[] = $maskPoint2;
                if ($endQuad == 2) {
                    $polyPoints[] = $maskPoint1;
                    $polyPoints[] = $maskPoint4;
                    $polyPoints[] = $maskPoint3;
                    $polyPoints[] = array('x' => $maskPoint3['x'], 'y' => $endPoint['y']);
                } else {
                    if ($endQuad == 3) {
                        $polyPoints[] = $maskPoint1;
                        $polyPoints[] = $maskPoint4;
                        $polyPoints[] = $maskPoint3;
                    } else {
                        if ($endQuad == 4) {
                            $polyPoints[] = $maskPoint1;
                            $polyPoints[] = $maskPoint4;
                        } else {
                            if ($endQuad == 1) {
                                $polyPoints[] = $maskPoint1;
                            }
                        }
                    }
                }
                break;
            case 3:
                $polyPoints[] = $maskPoint3;
                if ($endQuad == 3) {
                    $polyPoints[] = $maskPoint2;
                    $polyPoints[] = $maskPoint1;
                    $polyPoints[] = $maskPoint4;
                    $polyPoints[] = array('x' => $endPoint['x'], 'y' => $maskPoint4['y']);
                } else {
                    if ($endQuad == 4) {
                        $polyPoints[] = $maskPoint2;
                        $polyPoints[] = $maskPoint1;
                        $polyPoints[] = $maskPoint4;
                    } else {
                        if ($endQuad == 1) {
                            $polyPoints[] = $maskPoint2;
                            $polyPoints[] = $maskPoint1;
                        } else {
                            if ($endQuad == 2) {
                                $polyPoints[] = $maskPoint2;
                            }
                        }
                    }
                }
                break;
            case 4:
                $polyPoints[] = $maskPoint4;
                if ($endQuad == 4) {
                    $polyPoints[] = $maskPoint3;
                    $polyPoints[] = $maskPoint2;
                    $polyPoints[] = $maskPoint1;
                    $polyPoints[] = array('x' => $maskPoint1['x'], 'y' => $endPoint['y']);
                } else {
                    if ($endQuad == 1) {
                        $polyPoints[] = $maskPoint3;
                        $polyPoints[] = $maskPoint2;
                        $polyPoints[] = $maskPoint1;
                    } else {
                        if ($endQuad == 2) {
                            $polyPoints[] = $maskPoint3;
                            $polyPoints[] = $maskPoint2;
                        } else {
                            if ($endQuad == 3) {
                                $polyPoints[] = $maskPoint3;
                            }
                        }
                    }
                }
                break;
        }
        $polyPoints[] = $endPoint;
        $this->drawEllipse($x, $y, $w, $h, $fill);
        $this->drawClippingPolygon($polyPoints, true);
        return $this;
    }