diff options
| author | Matthew Petroff <matthew@mpetroff.net> | 2013-09-20 17:09:19 +0000 |
|---|---|---|
| committer | Matthew Petroff <matthew@mpetroff.net> | 2013-09-20 17:09:19 +0000 |
| commit | cf74f053a081f6f4b460da9cd72afaab23d54d13 (patch) | |
| tree | 427aa22ba3dcad9b55edb90522b5ab0208074e06 /src/sp-star.cpp | |
| parent | Using inkscape compact settings to save the icons.svg file (diff) | |
| parent | Merge from trunk. (diff) | |
| download | inkscape-cf74f053a081f6f4b460da9cd72afaab23d54d13.tar.gz inkscape-cf74f053a081f6f4b460da9cd72afaab23d54d13.zip | |
Merge Google Summer of Code unit improvement.
(bzr r12554)
Diffstat (limited to 'src/sp-star.cpp')
| -rw-r--r-- | src/sp-star.cpp | 49 |
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 |
