summaryrefslogtreecommitdiffstats
path: root/src/sp-star.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/sp-star.cpp')
-rw-r--r--src/sp-star.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/sp-star.cpp b/src/sp-star.cpp
index e5c5c7c25..bc3155caf 100644
--- a/src/sp-star.cpp
+++ b/src/sp-star.cpp
@@ -514,6 +514,55 @@ void SPStar::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::
}
}
+Geom::Affine SPStar::set_transform(Geom::Affine const &xform)
+{
+ // Only set transform with proportional scaling
+ if (!xform.withoutTranslation().isUniformScale()) {
+ return xform;
+ }
+
+ /* Calculate star start in parent coords. */
+ Geom::Point pos( this->center * xform );
+
+ /* This function takes care of translation and scaling, we return whatever parts we can't
+ handle. */
+ Geom::Affine ret(Geom::Affine(xform).withoutTranslation());
+ gdouble const s = hypot(ret[0], ret[1]);
+ if (s > 1e-9) {
+ ret[0] /= s;
+ ret[1] /= s;
+ ret[2] /= s;
+ ret[3] /= s;
+ } else {
+ ret[0] = 1.0;
+ ret[1] = 0.0;
+ ret[2] = 0.0;
+ ret[3] = 1.0;
+ }
+
+ this->r[0] *= s;
+ this->r[1] *= s;
+
+ /* Find start in item coords */
+ pos = pos * ret.inverse();
+ this->center = pos;
+
+ this->set_shape();
+
+ // Adjust stroke width
+ this->adjust_stroke(s);
+
+ // Adjust pattern fill
+ this->adjust_pattern(xform * ret.inverse());
+
+ // Adjust gradient fill
+ this->adjust_gradient(xform * ret.inverse());
+
+ this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
+
+ return ret;
+}
+
/**
* sp_star_get_xy: Get X-Y value as item coordinate system
* @star: star item