87 const bool constrainScale =
getBool(
"transform_keep_scale_aspect",
true);
88 const qreal scaleX =
getDouble(
"transform_scale_x", 1.0);
90 const qreal scaleY = constrainScale ? scaleX :
getDouble(
"transform_scale_y", 1.0);
91 const qreal positionX =
getInt(
"transform_offset_x", 0);
92 const qreal positionY =
getInt(
"transform_offset_y", 0);
93 const qreal shearX =
getDouble(
"transform_shear_x", 0.0);
94 const qreal shearY =
getDouble(
"transform_shear_y", 0.0);
95 const qreal rotationX =
getDouble(
"transform_rotation_x", 0.0);
96 const qreal rotationY =
getDouble(
"transform_rotation_y", 0.0);
97 const qreal rotationZ =
getDouble(
"transform_rotation_z", 0.0);
98 const bool align =
getBool(
"transform_align_to_pixel_grid",
false);
99 const qint32 alignX =
getInt(
"transform_align_to_pixel_grid_x", 1);
100 const qint32 alignY =
getInt(
"transform_align_to_pixel_grid_y", 1);
112 const QSizeF repetitionRectSize(
113 static_cast<qreal
>(alignX *
pattern()->width()),
114 static_cast<qreal
>(alignY *
pattern()->height())
119 const QPointF u1 =
transform.map(QPointF(repetitionRectSize.width(), 0.0));
120 const QPointF u2 =
transform.map(QPointF(0.0, repetitionRectSize.height()));
123 QPointF v1(qRound(u1.x()), qRound(u1.y()));
124 QPointF v2(qRound(u2.x()), qRound(u2.y()));
134 const QPointF *p_u = dist1 > dist2 ? &u1 : &u2;
135 QPointF *p_v = dist1 > dist2 ? &v1 : &v2;
138 QPair<int, qreal> dists[4]{
145 std::begin(dists), std::end(dists),
146 [](
const QPair<int, qreal> &a,
const QPair<int, qreal> &b)
148 return a.second < b.second;
152 if (dists[0].first == 1) {
153 p_v->setY(p_v->y() - 1.0);
154 }
else if (dists[0].first == 2) {
155 p_v->setX(p_v->x() + 1.0);
156 }
else if (dists[0].first == 3) {
157 p_v->setY(p_v->y() + 1.0);
159 p_v->setX(p_v->x() - 1.0);
165 quad.append(QPointF(0, 0));
166 quad.append(v1 / repetitionRectSize.width());
167 quad.append(v1 / repetitionRectSize.width() + v2 / repetitionRectSize.height());
168 quad.append(v2 / repetitionRectSize.height());
169 QTransform::quadToSquare(quad,
transform);
172 transform.translate(qRound(positionX), qRound(positionY));
179 transform.translate(positionX, positionY);