Pop\Pdf\Pdf::drawClippingEllipse PHP Method

drawClippingEllipse() public method

Method to add a clipping ellipse to the PDF.
public drawClippingEllipse ( integer $x, integer $y, integer $w, integer $h = null ) : Pdf
$x integer
$y integer
$w integer
$h integer
return Pdf
    public function drawClippingEllipse($x, $y, $w, $h = null)
    {
        $oldFillColor = $this->fillColor;
        $oldStrokeColor = $this->strokeColor;
        $oldStrokeWidth = $this->strokeWidth;
        $oldStrokeDashLength = $this->strokeDashLength;
        $oldStrokeDashGap = $this->strokeDashGap;
        $this->setFillColor($this->backgroundColor);
        $this->setStrokeWidth(false);
        if (null === $h) {
            $h = $w;
        }
        $x1 = $x + $w;
        $y1 = $y;
        $x2 = $x;
        $y2 = $y - $h;
        $x3 = $x - $w;
        $y3 = $y;
        $x4 = $x;
        $y4 = $y + $h;
        // Calculate coordinate number one's 2 bezier points.
        $coor1_bez1_x = $x1;
        $coor1_bez1_y = round(0.55 * ($y2 - $y1)) + $y1;
        $coor1_bez2_x = $x1;
        $coor1_bez2_y = round(0.45 * ($y1 - $y4)) + $y4;
        // Calculate coordinate number two's 2 bezier points.
        $coor2_bez1_x = round(0.45 * ($x2 - $x1)) + $x1;
        $coor2_bez1_y = $y2;
        $coor2_bez2_x = round(0.55 * ($x3 - $x2)) + $x2;
        $coor2_bez2_y = $y2;
        // Calculate coordinate number three's 2 bezier points.
        $coor3_bez1_x = $x3;
        $coor3_bez1_y = round(0.55 * ($y2 - $y3)) + $y3;
        $coor3_bez2_x = $x3;
        $coor3_bez2_y = round(0.45 * ($y3 - $y4)) + $y4;
        // Calculate coordinate number four's 2 bezier points.
        $coor4_bez1_x = round(0.55 * ($x3 - $x4)) + $x4;
        $coor4_bez1_y = $y4;
        $coor4_bez2_x = round(0.45 * ($x4 - $x1)) + $x1;
        $coor4_bez2_y = $y4;
        $co_index = $this->getContentObject();
        $this->objects[$co_index]->setStream("\n{$x1} {$y1} m\n{$coor1_bez1_x} {$coor1_bez1_y} {$coor2_bez1_x} {$coor2_bez1_y} {$x2} {$y2} c\n{$coor2_bez2_x} {$coor2_bez2_y} {$coor3_bez1_x} {$coor3_bez1_y} {$x3} {$y3} c\n{$coor3_bez2_x} {$coor3_bez2_y} {$coor4_bez1_x} {$coor4_bez1_y} {$x4} {$y4} c\n{$coor4_bez2_x} {$coor4_bez2_y} {$coor1_bez2_x} {$coor1_bez2_y} {$x1} {$y1} c\nW\nF\n");
        $this->setFillColor($oldFillColor);
        if (null !== $oldStrokeColor) {
            $this->setStrokeColor($oldStrokeColor);
            $this->setStrokeWidth($oldStrokeWidth, $oldStrokeDashLength, $oldStrokeDashGap);
        }
        return $this;
    }