Grafika\Gd\DrawingObject\QuadraticBezier::plot PHP Method

plot() protected method

protected plot ( $gd, $x0, $y0, $x1, $y1, $x2, $y2 )
    protected function plot($gd, $x0, $y0, $x1, $y1, $x2, $y2)
    {
        /* plot any quadratic Bezier curve */
        $x = $x0 - $x1;
        $y = $y0 - $y1;
        $t = $x0 - 2 * $x1 + $x2;
        //double
        if ((int) $x * ($x2 - $x1) > 0) {
            /* horizontal cut at P4? */
            if ((int) $y * ($y2 - $y1) > 0) {
                if (abs(($y0 - 2 * $y1 + $y2) / $t * $x) > abs($y)) {
                    /* which first? */
                    $x0 = $x2;
                    $x2 = $x + $x1;
                    $y0 = $y2;
                    $y2 = $y + $y1;
                    /* swap points */
                }
            }
            /* now horizontal cut at P4 comes first */
            $t = ($x0 - $x1) / $t;
            $r = (1 - $t) * ((1 - $t) * $y0 + 2.0 * $t * $y1) + $t * $t * $y2;
            /* By(t=P4) */
            $t = ($x0 * $x2 - $x1 * $x1) * $t / ($x0 - $x1);
            /* gradient dP4/dx=0 */
            $x = floor($t + 0.5);
            $y = floor($r + 0.5);
            $r = ($y1 - $y0) * ($t - $x0) / ($x1 - $x0) + $y0;
            /* intersect P3 | P0 P1 */
            $this->plotSegment($gd, $x0, $y0, $x, floor($r + 0.5), $x, $y);
            $r = ($y1 - $y2) * ($t - $x2) / ($x1 - $x2) + $y2;
            /* intersect P4 | P1 P2 */
            $x0 = $x1 = $x;
            $y0 = $y;
            $y1 = floor($r + 0.5);
            /* P0 = P4, P1 = P8 */
        }
        if ((int) ($y0 - $y1) * ($y2 - $y1) > 0) {
            /* vertical cut at P6? */
            $t = $y0 - 2 * $y1 + $y2;
            $t = ($y0 - $y1) / $t;
            $r = (1 - $t) * ((1 - $t) * $x0 + 2.0 * $t * $x1) + $t * $t * $x2;
            /* Bx(t=P6) */
            $t = ($y0 * $y2 - $y1 * $y1) * $t / ($y0 - $y1);
            /* gradient dP6/dy=0 */
            $x = floor($r + 0.5);
            $y = floor($t + 0.5);
            $r = ($x1 - $x0) * ($t - $y0) / ($y1 - $y0) + $x0;
            /* intersect P6 | P0 P1 */
            $this->plotSegment($gd, $x0, $y0, floor($r + 0.5), $y, $x, $y);
            $r = ($x1 - $x2) * ($t - $y2) / ($y1 - $y2) + $x2;
            /* intersect P7 | P1 P2 */
            $x0 = $x;
            $x1 = floor($r + 0.5);
            $y0 = $y1 = $y;
            /* P0 = P6, P1 = P7 */
        }
        $this->plotSegment($gd, $x0, $y0, $x1, $y1, $x2, $y2);
        /* remaining part */
    }