29QQuickPathInterpolated::QQuickPathInterpolated(QObject *parent) : QQuickCurve{ parent }
31 connect(
this, &QQuickPathInterpolated::factorChanged,
this, &QQuickPathElement::changed);
32 connect(
this, &QQuickPathInterpolated::svgPathsChanged,
this, &QQuickPathElement::changed);
79void QQuickPathInterpolated::addToPath(QPainterPath &path,
const QQuickPathData &)
81 const qsizetype pathCount = m_svgPaths.size();
84 m_paths.resize(pathCount);
85 for (qsizetype i = 0; i < pathCount; i++) {
86 if (!QQuickSvgParser::parsePathDataFast(m_svgPaths.at(i), m_paths[i]))
87 qCDebug(lcPath) <<
"Syntax error in svg path no." << i;
91 Q_ASSERT(m_paths.size() == pathCount);
93 if (m_paths.isEmpty())
97 qreal factorIntValue = 0;
98 const qreal f = std::modf(m_factor, &factorIntValue);
99 const qsizetype pathIdx = qsizetype(qBound(qreal(0), factorIntValue, qreal(pathCount - 1)));
101 if (m_paths.size() == 1 || (pathIdx == 0 && f <= 0)) {
102 res = m_paths.first();
104 res = m_paths.at(pathIdx);
105 if ((pathIdx < pathCount - 1) && f > 0) {
106 const QPainterPath &p0 = m_paths.at(pathIdx);
107 const QPainterPath &p1 = m_paths.at(pathIdx + 1);
108 if (p0.elementCount() == p1.elementCount()) {
109 for (qsizetype i = 0; i < p0.elementCount(); i++) {
110 QPainterPath::Element e0 = p0.elementAt(i);
111 QPainterPath::Element e1 = p1.elementAt(i);
112 if (e0.type != e1.type) {
113 qCDebug(lcPath) <<
"Differing elements in svg path no." << i;
116 QPointF cp = QPointF(e0) + f * (QPointF(e1) - QPointF(e0));
117 res.setElementPositionAt(i, cp.x(), cp.y());
120 qCDebug(lcPath) <<
"Differing element count in svg path no." << pathIdx + 1;