};
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();
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
};
}
}
-// 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
#include "qmath.h"
#include "qnumeric.h"
#include "qcorecommon_p.h"
+#include "qguicommon_p.h"
QT_BEGIN_NAMESPACE
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
&& 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);
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;
};