Details
-
Bug
-
Resolution: Duplicate
-
P2: Important
-
4.6.3
-
None
-
c41dbbb5e6495e26cd3223d39c61decd951afeba, 119d7dddc8da189ccd1cbc55ed3292f311c30e0c, c46688b8a88da02028405604ab633b27d3fefa68
Description
This code gives a bad representation of the intended Curve:
QPainter p(this); p.setRenderHint(QPainter::Antialiasing, true); QPen pe(Qt::red); pe.setWidth(5); QVector<qreal> v; v << 20; v << 20; pe.setDashPattern(v); pe.setDashOffset(i/10.0f); p.setPen(pe); QPainterPath path; path.moveTo(0,20); path.cubicTo(0, 0, 20, 0, 30, 20); p.scale(width()/40, width()/40); p.drawPath(path);
You can see that it draws Lines instead of a curve. This comes from QBezier::toPolygon not taking into account the current scaling of the matrix. It assumes that the control point coordinates map directly to pixels which is not the case.
I fixed it in QBezier / QDashStroker / QPaintEngineEx by forwarding the scale factor and dividing "flatness/scale" in Qbezier.cpp:248:
if (d < (flatness/_scaleMax)*l || b == beziers + 31) {
This works but is not perfect, finding the right scaleMax is non obvious.
Cheers,
Marcus