10#include <private/qnumeric_p.h>
81 d =
qAbs( (x4x1)*(
b->y1 -
b->y2) - (y4y1)*(
b->x1 -
b->x2) )
82 +
qAbs( (x4x1)*(
b->y1 -
b->y3) - (y4y1)*(
b->x1 -
b->x3) );
88 if (
d < bezier_flattening_threshold * l ||
levels[
top] == 0) {
94 std::tie(
b[1],
b[0]) =
b->split();
117 d =
qAbs( (x4x1)*(
b->y1 -
b->y2) - (y4y1)*(
b->x1 -
b->x2) )
118 +
qAbs( (x4x1)*(
b->y1 -
b->y3) - (y4y1)*(
b->x1 -
b->x3) );
124 if (
d < bezier_flattening_threshold * l ||
levels[
top] == 0) {
130 std::tie(
b[1],
b[0]) =
b->split();
168 return QRectF(xmin, ymin, xmax-xmin, ymax-ymin);
184 const int divisions = 4;
187 for (
int i = 1;
i < divisions; ++
i,
t +=
spacing) {
191 if (
qAbs(
d - o2) > max_dist_line)
194 QPointF normalPoint = b1->normalVector(
t);
196 if (l !=
qreal(0.0)) {
197 d =
qAbs( normalPoint.x()*(
p1.y() -
p2.y()) - normalPoint.y()*(
p1.x() -
p2.x()) ) / l;
198 if (
d > max_dist_normal)
240 (orig->
y1 - orig->
y2)*(orig->
y1 - orig->
y2) *
241 (orig->
x3 - orig->
x4)*(orig->
x3 - orig->
x4) +
242 (orig->
y3 - orig->
y4)*(orig->
y3 - orig->
y4);
244 (orig->
y1 - orig->
y2)*(orig->
y3 - orig->
y4);
260 for (
int i = 1;
i < np - 1; ++
i) {
262 QPointF next_normal =
next.normalVector().unitVector().p2();
264 QPointF normal_sum = prev_normal + next_normal;
266 qreal r =
qreal(1.0) + prev_normal.
x() * next_normal.x()
267 + prev_normal.y() * next_normal.y();
273 points_shifted[
i] =
points[
i] + k * normal_sum;
276 prev_normal = next_normal;
279 points_shifted[np - 1] =
points[np - 1] +
offset * prev_normal;
282 points_shifted[
map[2]], points_shifted[
map[3]]);
292#define KAPPA qreal(0.5522847498)
299 normals[0] =
QPointF(
b->y2 -
b->y1,
b->x1 -
b->x2);
304 normals[2] =
QPointF(
b->y4 -
b->y3,
b->x3 -
b->x4);
305 dist =
qSqrt(normals[2].
x()*normals[2].
x() + normals[2].
y()*normals[2].
y());
310 normals[1] =
QPointF(
b->x1 -
b->x2 -
b->x3 +
b->x4,
b->y1 -
b->y2 -
b->y3 +
b->y4);
311 normals[1] /= -1*
qSqrt(normals[1].
x()*normals[1].
x() + normals[1].
y()*normals[1].
y());
315 for (
int i = 0;
i < 2; ++
i) {
316 qreal cos_a = normals[
i].
x()*normals[
i+1].
x() + normals[
i].
y()*normals[
i+1].
y();
324 if (angles[0] + angles[1] > 1.) {
326 normals[1] = -normals[1];
327 angles[0] = 1. - angles[0];
328 angles[1] = 1. - angles[1];
338 for (
int i = 0;
i < 2; ++
i) {
341 o->x1 = circle[
i].
x();
342 o->y1 = circle[
i].
y();
343 o->x2 = circle[
i].
x() - normals[
i].
y()*kappa;
344 o->y2 = circle[
i].
y() + normals[
i].
x()*kappa;
345 o->x3 = circle[
i+1].
x() + normals[
i+1].
y()*kappa;
346 o->y3 = circle[
i+1].
y() - normals[
i+1].
x()*kappa;
347 o->x4 = circle[
i+1].
x();
348 o->y4 = circle[
i+1].
y();
371 while (
b >= beziers) {
372 int stack_segments =
b - beziers + 1;
373 if ((stack_segments == 10) || (
o - curveSegments == maxSegments - stack_segments)) {
374 threshold *=
qreal(1.5);
375 if (threshold >
qreal(2.0))
382 }
else if (
res ==
Ok) {
385 }
else if (
res ==
Circle && maxSegments - (
o - curveSegments) >= 2) {
391 std::tie(
b[1],
b[0]) =
b->split();
397 while (
b >= beziers) {
407 Q_ASSERT(
o - curveSegments <= maxSegments);
408 return o - curveSegments;
414 dbg <<
'[' <<
bz.x1<<
", " <<
bz.y1 <<
"], "
415 <<
'[' <<
bz.x2 <<
", " <<
bz.y2 <<
"], "
416 <<
'[' <<
bz.x3 <<
", " <<
bz.y3 <<
"], "
417 <<
'[' <<
bz.x4 <<
", " <<
bz.y4 <<
']';
443 const auto halves =
split();
511 return t0 > 0 &&
t0 < 1;
518 return t0 > 0 &&
t0 < 1;
519 }
else if (reciprocal > 0) {
522 t0 = (-
b - temp)/(2*
a);
523 t1 = (-
b + temp)/(2*
a);
531 if (
t0 > 0 &&
t0 < 1)
533 if (
t1 > 0 &&
t1 < 1)
567 t += (lastBigger -
t) *
qreal(0.5);
580 if (
t0 == 0 &&
t1 == 1)
qreal tForY(qreal t0, qreal t1, qreal y) const
static QBezier fromPoints(const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4)
std::pair< QBezier, QBezier > split() const
QPointF pointAt(qreal t) const
void parameterSplitLeft(qreal t, QBezier *left)
qreal tAtLength(qreal len) const
QPolygonF toPolygon(qreal bezier_flattening_threshold=0.5) const
int shifted(QBezier *curveSegments, int maxSegmets, qreal offset, float threshold) const
QBezier bezierOnInterval(qreal t0, qreal t1) const
static void coefficients(qreal t, qreal &a, qreal &b, qreal &c, qreal &d)
int stationaryYPoints(qreal &t0, qreal &t1) const
QBezier mapBy(const QTransform &transform) const
qreal length(qreal error=0.01) const
void addIfClose(qreal *length, qreal error) const
void addToPolygon(QPolygonF *p, qreal bezier_flattening_threshold=0.5) const
QBezier getSubRange(qreal t0, qreal t1) const
\inmodule QtCore\compares equality \compareswith equality QLine \endcompareswith
qreal length() const
Returns the length of the line.
constexpr QLineF normalVector() const
Returns a line that is perpendicular to this line with the same starting point and length.
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
The QPolygonF class provides a list of points using floating point precision.
\inmodule QtCore\reentrant
QMap< QString, QString > map
[6]
Combined button and popup list for selecting options.
static QT_WARNING_DISABLE_FLOAT_COMPARE ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qreal threshold)
static ShiftResult good_offset(const QBezier *b1, const QBezier *b2, qreal offset, qreal threshold)
static bool addCircle(const QBezier *b, qreal offset, QBezier *o)
#define QT_WARNING_DISABLE_FLOAT_COMPARE
DBusConnection const char DBusError * error
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
bool qFuzzyIsNull(qfloat16 f) noexcept
qfloat16 qSqrt(qfloat16 f)
constexpr T qAbs(const T &t)
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLuint GLfloat GLfloat GLfloat x1
GLenum GLuint GLenum GLsizei length
GLdouble GLdouble GLdouble GLdouble top
GLenum GLenum GLsizei count
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
[4]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
GLenum GLuint GLintptr offset
GLuint GLenum GLenum transform
GLfixed GLfixed GLint GLint GLfixed points
GLfixed GLfixed GLfixed y2
static qreal dot(const QPointF &a, const QPointF &b)
QT_BEGIN_NAMESPACE constexpr void qSwap(T &value1, T &value2) noexcept(std::is_nothrow_swappable_v< T >)
std::uniform_real_distribution dist(1, 2.5)
[2]