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

QPointF QPainterPath::pointAtPercent ( qreal  t  )  const

Returns the point at at the percentage t of the current path. The argument t has to be between 0 and 1.

Note that similarly to other percent methods, the percentage measurment is not linear with regards to the length, if curves are present in the path. When curves are present the percentage argument is mapped to the t parameter of the Bezier equations.

Definition at line 2722 of file qpainterpath.cpp.

References isEmpty(), and length().

    if (t < 0 || t > 1) {
        qWarning("QPainterPath::pointAtPercent accepts only values between 0 and 1");
        return QPointF();

    if (isEmpty())
        return QPointF();

    qreal totalLength = length();
    qreal curLen = 0;
    qreal bezierLen = 0;
    QBezier b = bezierAtT(*this, t, &curLen, &bezierLen);
    qreal realT = (totalLength * t - curLen) / bezierLen;

    return b.pointAt(realT);

Generated by  Doxygen 1.6.0   Back to index