Horde_Pdf_Writer::circle PHP Method

circle() public method

All coordinates can be negative to provide values from the right or bottom edge of the page (since File_Pdf 0.2.0, Horde 3.2).
public circle ( float $x, float $y, float $r, string $style = '' )
$x float Abscissa of the center of the circle.
$y float Ordinate of the center of the circle.
$r float Circle radius.
$style string Style of rendering. Possible values are: - D or empty string: draw (default) - F: fill - DF or FD: draw and fill
    public function circle($x, $y, $r, $style = '')
    {
        if ($x < 0) {
            $x += $this->w;
        }
        if ($y < 0) {
            $y += $this->h;
        }
        $style = Horde_String::lower($style);
        if ($style == 'f') {
            $op = 'f';
            // Style is fill only.
        } elseif ($style == 'fd' || $style == 'df') {
            $op = 'B';
            // Style is fill and stroke.
        } else {
            $op = 'S';
            // Style is stroke only.
        }
        $x = $this->_toPt($x);
        $y = $this->_toPt($y);
        $r = $this->_toPt($r);
        /* Invert the y scale. */
        $y = $this->hPt - $y;
        /* Length of the Bezier control. */
        $b = $r * 0.552;
        /* Move from the given origin and set the current point
         * to the start of the first Bezier curve. */
        $c = sprintf('%.2F %.2F m', $x - $r, $y);
        $x = $x - $r;
        /* First circle quarter. */
        $c .= sprintf(' %.2F %.2F %.2F %.2F %.2F %.2F c', $x, $y + $b, $x + $r - $b, $y + $r, $x + $r, $y + $r);
        // Final point.
        /* Set x/y to the final point. */
        $x = $x + $r;
        $y = $y + $r;
        /* Second circle quarter. */
        $c .= sprintf(' %.2F %.2F %.2F %.2F %.2F %.2F c', $x + $b, $y, $x + $r, $y - $r + $b, $x + $r, $y - $r);
        /* Set x/y to the final point. */
        $x = $x + $r;
        $y = $y - $r;
        /* Third circle quarter. */
        $c .= sprintf(' %.2F %.2F %.2F %.2F %.2F %.2F c', $x, $y - $b, $x - $r + $b, $y - $r, $x - $r, $y - $r);
        /* Set x/y to the final point. */
        $x = $x - $r;
        $y = $y - $r;
        /* Fourth circle quarter. */
        $c .= sprintf(' %.2F %.2F %.2F %.2F %.2F %.2F c %s', $x - $b, $y, $x - $r, $y + $r - $b, $x - $r, $y + $r, $op);
        /* Output the whole string. */
        $this->_out($c);
    }