44 auto xformProp = transform();
45 xformProp.clear(&xformProp);
46 bool translate = !qFuzzyIsNull(m_viewBox.x()) || !qFuzzyIsNull(m_viewBox.y());
48 auto *tr =
new QQuickTranslate(
this);
49 tr->setX(-m_viewBox.x());
50 tr->setY(-m_viewBox.y());
51 xformProp.append(&xformProp, tr);
53 if (!m_viewBox.isEmpty() && width() && height()) {
54 auto *scale =
new QQuickScale(
this);
55 qreal sx = width() / m_viewBox.width();
56 qreal sy = height() / m_viewBox.height();
60 xformProp.append(&xformProp, scale);
123 QRect pixelRect(objModeRect.x() * boundingRect.width() + boundingRect.left(),
124 objModeRect.y() * boundingRect.height() + boundingRect.top(),
125 objModeRect.width() * boundingRect.width(),
126 objModeRect.height() * boundingRect.height());
128 if (pixelRect.isEmpty())
131 double w = boundingRect.width();
132 double h = boundingRect.height();
133 double objModeSlope = objModeRect.height() / objModeRect.width();
134 double a = objModeSlope * w / h;
137 double x2 = pixelRect.width();
138 double y2 = pixelRect.height();
139 double x = (x2 + a * y2) / (1 + a * a);
140 double y = y2 - (x - x2)/a;
142 return QRectF(pixelRect.topLeft(), QSizeF(x,y));
147 QString svgPathString;
148 QTextStream strm(&svgPathString);
150 for (
int i = 0; i < path.elementCount(); ++i) {
151 QPainterPath::Element element = path.elementAt(i);
152 if (element.isMoveTo()) {
153 strm <<
"M " << element.x <<
" " << element.y <<
" ";
154 }
else if (element.isLineTo()) {
155 strm <<
"L " << element.x <<
" " << element.y <<
" ";
156 }
else if (element.isCurveTo()) {
157 QPointF c1(element.x, element.y);
159 element = path.elementAt(i);
161 QPointF c2(element.x, element.y);
163 element = path.elementAt(i);
164 QPointF ep(element.x, element.y);
176 return svgPathString;