diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp index c8645e4ef..ad3bfd00d 100644 --- a/src/gui/painting/qbezier.cpp +++ b/src/gui/painting/qbezier.cpp @@ -318,7 +318,7 @@ static bool addCircle(const QBezier *b, qreal offset, QBezier *o) }; for (int i = 0; i < 2; ++i) { - qreal kappa = qreal(2.0) * KAPPA * sign * offset * angles[i]; + qreal kappa = qreal(2.0) * QT_PATH_KAPPA * sign * offset * angles[i]; o->x1 = circle[i].x(); o->y1 = circle[i].y(); diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 97b950c8b..a38baa922 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -631,20 +631,20 @@ void QPaintEngineEx::drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yR qreal pts[] = { x1 + xRadius, y1, // MoveTo x2 - xRadius, y1, // LineTo - x2 - (1 - KAPPA) * xRadius, y1, // CurveTo - x2, y1 + (1 - KAPPA) * yRadius, + x2 - (1 - QT_PATH_KAPPA) * xRadius, y1, // CurveTo + x2, y1 + (1 - QT_PATH_KAPPA) * yRadius, x2, y1 + yRadius, x2, y2 - yRadius, // LineTo - x2, y2 - (1 - KAPPA) * yRadius, // CurveTo - x2 - (1 - KAPPA) * xRadius, y2, + x2, y2 - (1 - QT_PATH_KAPPA) * yRadius, // CurveTo + x2 - (1 - QT_PATH_KAPPA) * xRadius, y2, x2 - xRadius, y2, x1 + xRadius, y2, // LineTo - x1 + (1 - KAPPA) * xRadius, y2, // CurveTo - x1, y2 - (1 - KAPPA) * yRadius, + x1 + (1 - QT_PATH_KAPPA) * xRadius, y2, // CurveTo + x1, y2 - (1 - QT_PATH_KAPPA) * yRadius, x1, y2 - yRadius, x1, y1 + yRadius, // LineTo - x1, y1 + (1 - KAPPA) * yRadius, // CurveTo - x1 + (1 - KAPPA) * xRadius, y1, + x1, y1 + (1 - QT_PATH_KAPPA) * yRadius, // CurveTo + x1 + (1 - QT_PATH_KAPPA) * xRadius, y1, x1 + xRadius, y1 }; diff --git a/src/gui/painting/qpainterpath_p.h b/src/gui/painting/qpainterpath_p.h index fc97f1ac0..ea753b9bc 100644 --- a/src/gui/painting/qpainterpath_p.h +++ b/src/gui/painting/qpainterpath_p.h @@ -246,11 +246,6 @@ inline void QPainterPathPrivate::maybeMoveTo() } } -// This value is used to determine the length of control point vectors -// when approximating arc segments as curves. The factor is multiplied -// with the radius of the circle. -#define KAPPA qreal(0.5522847498) - QT_END_NAMESPACE #endif // QPAINTERPATH_P_H diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp index 7fb1a9e94..02120d3c9 100644 --- a/src/gui/painting/qstroker.cpp +++ b/src/gui/painting/qstroker.cpp @@ -26,6 +26,7 @@ #include "qmath.h" #include "qnumeric.h" #include "qcorecommon_p.h" +#include "qguicommon_p.h" QT_BEGIN_NAMESPACE @@ -743,18 +744,18 @@ template bool qt_stroke_side(Iterator *it, For a given angle in the range [0 .. 90], finds the corresponding parameter t of the prototype cubic bezier arc segment - b = fromPoints(QPointF(1, 0), QPointF(1, KAPPA), QPointF(KAPPA, 1), QPointF(0, 1)); + b = fromPoints(QPointF(1, 0), QPointF(1, QT_PATH_KAPPA), QPointF(QT_PATH_KAPPA, 1), QPointF(0, 1)); From the bezier equation: - b.pointAt(t).x() = (1-t)^3 + t*(1-t)^2 + t^2*(1-t)*KAPPA - b.pointAt(t).y() = t*(1-t)^2 * KAPPA + t^2*(1-t) + t^3 + b.pointAt(t).x() = (1-t)^3 + t*(1-t)^2 + t^2*(1-t)*QT_PATH_KAPPA + b.pointAt(t).y() = t*(1-t)^2 * QT_PATH_KAPPA + t^2*(1-t) + t^3 Third degree coefficients: b.pointAt(t).x() = at^3 + bt^2 + ct + d - where a = 2-3*KAPPA, b = 3*(KAPPA-1), c = 0, d = 1 + where a = 2-3*QT_PATH_KAPPA, b = 3*(QT_PATH_KAPPA-1), c = 0, d = 1 b.pointAt(t).y() = at^3 + bt^2 + ct + d - where a = 3*KAPPA-2, b = 6*KAPPA+3, c = 3*KAPPA, d = 0 + where a = 3*QT_PATH_KAPPA-2, b = 6*QT_PATH_KAPPA+3, c = 3*QT_PATH_KAPPA, d = 0 Newton's method to find the zero of a function: given a function f(x) and initial guess x_0 diff --git a/src/gui/painting/qstroker_p.h b/src/gui/painting/qstroker_p.h index 5e5f1cd6a..2ab73ede4 100644 --- a/src/gui/painting/qstroker_p.h +++ b/src/gui/painting/qstroker_p.h @@ -47,8 +47,6 @@ struct qfixed2d && qFuzzyCompare(y, other.y); } }; -#define QT_PATH_KAPPA 0.5522847498 - QPointF qt_curves_for_arc(const QRectF &rect, qreal startAngle, qreal sweepLength, QPointF *controlPoints, int *point_count); diff --git a/src/gui/qguicommon_p.h b/src/gui/qguicommon_p.h index 6b0f9031b..a521e235c 100644 --- a/src/gui/qguicommon_p.h +++ b/src/gui/qguicommon_p.h @@ -9,6 +9,11 @@ QT_BEGIN_NAMESPACE +// This value is used to determine the length of control point vectors +// when approximating arc segments as curves. The factor is multiplied +// with the radius of the circle. +#define QT_PATH_KAPPA qreal(0.5522847498) + struct QRealRect { qreal x1, y1, x2, y2; };