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

void QPainter::drawConvexPolygon ( const QPointF points,
int  pointCount 
) [inherited]

Draws the convex polygon defined by the first pointCount points in the array points using the current pen.

100% qpainter-polygon.png

    static const QPointF points[4] = {
        QPointF(10.0, 80.0),
        QPointF(20.0, 10.0),
        QPointF(80.0, 30.0),
        QPointF(90.0, 70.0)
    };

    QPainter painter(this);
    painter.drawConvexPolygon(points, 4);

The first point is implicitly connected to the last point, and the polygon is filled with the current brush(). If the supplied polygon is not convex, i.e. it contains at least one angle larger than 180 degrees, the results are undefined.

On some platforms (e.g. X11), the drawConvexPolygon() function can be faster than the drawPolygon() function.

See also:
drawPolygon(), drawPolyline(), {The Coordinate System}

Definition at line 4041 of file qpainter.cpp.

References QPainterPath::closeSubpath(), QPainter::isActive(), QPainterPath::lineTo(), and QPainterPath::setFillRule().

Referenced by QPainter::drawConvexPolygon().

{
#ifdef QT_DEBUG_DRAW
    if (qt_show_painter_debug_output)
        printf("QPainter::drawConvexPolygon(), count=%d\n", pointCount);
#endif

    if (!isActive() || pointCount < 2)
        return;

    Q_D(QPainter);
    d->updateState(d->state);

    uint emulationSpecifier = d->state->emulationSpecifier;

    if (emulationSpecifier) {
        QPainterPath polygonPath(points[0]);
        for (int i=1; i<pointCount; ++i)
            polygonPath.lineTo(points[i]);
        polygonPath.closeSubpath();
        polygonPath.setFillRule(Qt::WindingFill);
        d->draw_helper(polygonPath);
        return;
    }

    d->engine->drawPolygon(points, pointCount, QPaintEngine::ConvexMode);
}


Generated by  Doxygen 1.6.0   Back to index