6#include <private/qbezier_p.h>
13 static bool init =
false;
14 const int numSteps = 21;
16 static qreal t2s[numSteps];
17 static qreal tmts[numSteps];
21 const qreal step = (1 - (2 *
t)) / (numSteps - 1);
22 for (
int i = 0;
i < numSteps;
i++) {
24 tmts[
i] = 2 *
t * (1 -
t);
30 const QPointF midPoint =
b.midPoint();
31 auto distForIndex = [&](
int i) ->
qreal {
32 QPointF qp = (t2s[numSteps - 1 -
i] *
b.pt1()) + (tmts[
i] * qcp) + (t2s[
i] *
b.pt4());
37 const int halfSteps = (numSteps - 1) / 2;
39 const qreal centerDist = distForIndex(halfSteps);
40 qreal minDist = centerDist;
42 for (
int i = 0;
i < halfSteps;
i++) {
43 qreal tDist = distForIndex(halfSteps + 1 +
i);
44 if (tDist < minDist) {
54 for (
int i = 0;
i < halfSteps;
i++) {
55 qreal tDist = distForIndex(halfSteps - 1 -
i);
56 if (tDist < minDist) {
64 return foundIt ? minDist : centerDist;
69 const QLineF st =
b.startTangent();
70 const QLineF et =
b.endTangent();
71 const QPointF midPoint =
b.midPoint();
79 const QPointF ml = midPoint -
b.pt1();
80 const QPointF ql = quadControlPoint -
b.pt1();
81 qreal cx1 = (ml.
x() * bl.
y()) - (ml.
y() * bl.
x());
82 qreal cx2 = (ql.
x() * bl.
y()) - (ql.
y() * bl.
x());
83 valid = (std::signbit(cx1) == std::signbit(cx2));
85 return valid ? quadControlPoint : midPoint;
90 auto isValidRoot = [](
qreal r) {
104 const qreal x3 =
n.pt3().x();
105 const qreal x4 =
n.pt4().x();
107 const qreal y3 =
n.pt3().y();
114 const qreal a = 18 * ((-3 *
p) + (2 *
q) + (3 *
r) -
s);
116 if (std::signbit(
y2) != std::signbit(y3) &&
qFuzzyCompare(
float(x4 - x3),
float(
x2))) {
123 const qreal b = 18 * (((3 *
p) -
q) - (3 *
r));
129 const qreal root1 = (-
b + sqr) / (2 *
a);
130 const qreal root2 = (-
b - sqr) / (2 *
a);
133 if (isValidRoot(root1))
134 tpoints[
res++] = root1;
135 if (root2 != root1 && isValidRoot(root2))
136 tpoints[
res++] = root2;
138 if (
res == 2 && tpoints[0] > tpoints[1])
139 qSwap(tpoints[0], tpoints[1]);
162 out->append(
b.pt1());
166 const qreal f = 3.0 / 2.0;
167 const QPointF c1 =
b.pt1() +
f * (
b.pt2() -
b.pt1());
171 out->append(
b.pt4());
182 const int maxSubSplits = numInfPoints > 0 ? 2 : 3;
185 for (
int i = 0;
i < numInfPoints + 1;
i++) {
186 qreal t1 = (
i < numInfPoints) ? infPoints[
i] : 1;
void parameterSplitLeft(qreal t, QBezier *left)
QBezier bezierOnInterval(qreal t0, qreal t1) const
QBezier mapBy(const QTransform &transform) const
IntersectionType intersects(const QLineF &l, QPointF *intersectionPoint=nullptr) const
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
static constexpr qreal dotProduct(const QPointF &p1, const QPointF &p2)
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
The QPolygonF class provides a list of points using floating point precision.
\inmodule QtCore\reentrant
constexpr QPointF topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr QPointF bottomRight() const noexcept
Returns the position of the rectangle's bottom-right corner.
Combined button and popup list for selecting options.
#define Q_STATIC_ASSERT(Condition)
bool qIsFinite(qfloat16 f) noexcept
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
bool qFuzzyIsNull(qfloat16 f) noexcept
qfloat16 qSqrt(qfloat16 f)
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
[4]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
GLfixed GLfixed GLfixed y2
GLdouble GLdouble GLdouble GLdouble q
static void qt_addToQuadratics(const QBezier &b, QPolygonF *p, int maxSplits, qreal maxDiff)
static QPointF qt_quadraticForCubic(const QBezier &b)
void qt_toQuadratics(const QBezier &b, QPolygonF *out, qreal errorLimit)
static QT_BEGIN_NAMESPACE qreal qt_scoreQuadratic(const QBezier &b, QPointF qcp)
static int qt_getInflectionPoints(const QBezier &orig, qreal *tpoints)
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
QTextStream out(stdout)
[7]