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 std::optional<QPainterPath> qpath = QGuiSvg::parsePath(m_svgPaths.at(i));
88 m_paths[i] = qpath.value();
90 qCDebug(lcPath) <<
"Syntax error in svg path no." << i;
94 Q_ASSERT(m_paths.size() == pathCount);
96 if (m_paths.isEmpty())
100 qreal factorIntValue = 0;
101 const qreal f = std::modf(m_factor, &factorIntValue);
102 const qsizetype pathIdx = qsizetype(qBound(qreal(0), factorIntValue, qreal(pathCount - 1)));
104 if (m_paths.size() == 1 || (pathIdx == 0 && f <= 0)) {
105 res = m_paths.first();
107 res = m_paths.at(pathIdx);
108 if ((pathIdx < pathCount - 1) && f > 0) {
109 const QPainterPath &p0 = m_paths.at(pathIdx);
110 const QPainterPath &p1 = m_paths.at(pathIdx + 1);
111 if (p0.elementCount() == p1.elementCount()) {
112 for (qsizetype i = 0; i < p0.elementCount(); i++) {
113 QPainterPath::Element e0 = p0.elementAt(i);
114 QPainterPath::Element e1 = p1.elementAt(i);
115 if (e0.type != e1.type) {
116 qCDebug(lcPath) <<
"Differing elements in svg path no." << i;
119 QPointF cp = QPointF(e0) + f * (QPointF(e1) - QPointF(e0));
120 res.setElementPositionAt(i, cp.x(), cp.y());
123 qCDebug(lcPath) <<
"Differing element count in svg path no." << pathIdx + 1;