summaryrefslogtreecommitdiffstats
path: root/src/live_effects/parameter/powerstrokepointarray.cpp
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2014-10-18 15:03:29 +0000
committerJohan B. C. Engelen <j.b.c.engelen@alumnus.utwente.nl>2014-10-18 15:03:29 +0000
commit3b585aa639d46417beb401847600e5918406e5c1 (patch)
tree0397b46c558a10756f049b42a61824935bd05a55 /src/live_effects/parameter/powerstrokepointarray.cpp
parentRefactoring hatch to remove memory leaks (bad GTKish casting macros) and unin... (diff)
downloadinkscape-3b585aa639d46417beb401847600e5918406e5c1.tar.gz
inkscape-3b585aa639d46417beb401847600e5918406e5c1.zip
LPE Powerstroke, editing behavior: implement scaling of strokepath width when the proportional-stroke-scaling toggle is on.
Patch by Javier, tweaks by Johan. (bzr r13623)
Diffstat (limited to 'src/live_effects/parameter/powerstrokepointarray.cpp')
-rw-r--r--src/live_effects/parameter/powerstrokepointarray.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/live_effects/parameter/powerstrokepointarray.cpp b/src/live_effects/parameter/powerstrokepointarray.cpp
index 647986da6..420195aa8 100644
--- a/src/live_effects/parameter/powerstrokepointarray.cpp
+++ b/src/live_effects/parameter/powerstrokepointarray.cpp
@@ -68,9 +68,23 @@ PowerStrokePointArrayParam::param_newWidget()
}
-void PowerStrokePointArrayParam::param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/)
+void PowerStrokePointArrayParam::param_transform_multiply(Geom::Affine const &postmul, bool /*set*/)
{
-// param_set_and_write_new_value( (*this) * postmul );
+ // Check if proportional stroke-width scaling is on
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool transform_stroke = prefs ? prefs->getBool("/options/transform/stroke", true) : true;
+ if (transform_stroke) {
+ std::vector<Geom::Point> result;
+ result.reserve(_vector.size()); // reserve space for the points that will be added in the for loop
+ for (std::vector<Geom::Point>::const_iterator point_it = _vector.begin(), e = _vector.end();
+ point_it != e; ++point_it)
+ {
+ // scale each width knot with the average scaling in X and Y
+ Geom::Coord const A = (*point_it)[Geom::Y] * ((postmul.expansionX() + postmul.expansionY()) / 2);
+ result.push_back(Geom::Point((*point_it)[Geom::X], A));
+ }
+ param_set_and_write_new_value(result);
+ }
}