Logo Search packages:      
Sourcecode: qt4-x11 version File versions

void QPainterPath::quadTo ( const QPointF c,
const QPointF endPoint 
)

Adds a quadratic Bezier curve between the current position and the given endPoint with the control point specified by c.

After the curve is added, the current point is updated to be at the end point of the curve.

See also:
cubicTo(), {QPainterPath::Composing a QPainterPath}{Composing a QPainterPath}

Definition at line 777 of file qpainterpath.cpp.

References cubicTo(), elementCount(), QPointF::x(), and QPointF::y().

Referenced by quadTo().

{
#ifdef QPP_DEBUG
    printf("QPainterPath::quadTo() (%.2f,%.2f), (%.2f,%.2f)\n",
           c.x(), c.y(), e.x(), e.y());
#endif
#ifndef QT_NO_DEBUG
    if (qt_is_nan(c.x()) || qt_is_nan(c.y()) || qt_is_nan(e.x()) || qt_is_nan(e.y()))
        qWarning("QPainterPath::quadTo: Adding point where x or y is NaN, results are undefined");
#endif
    ensureData();
    detach();

    Q_D(QPainterPath);
    Q_ASSERT(!d->elements.isEmpty());
    const QPainterPath::Element &elm = d->elements.at(elementCount()-1);
    QPointF prev(elm.x, elm.y);

    // Abort on empty curve as a stroker cannot handle this and the
    // curve is irrelevant anyway.
    if (prev == c && c == e)
        return;

    QPointF c1((prev.x() + 2*c.x()) / 3, (prev.y() + 2*c.y()) / 3);
    QPointF c2((e.x() + 2*c.x()) / 3, (e.y() + 2*c.y()) / 3);
    cubicTo(c1, c2, e);
}


Generated by  Doxygen 1.6.0   Back to index