Code

Add "scale y stroke" parameter to Curve Stitching LPE
authorjohanengelen <johanengelen@users.sourceforge.net>
Fri, 31 Aug 2007 16:17:13 +0000 (16:17 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Fri, 31 Aug 2007 16:17:13 +0000 (16:17 +0000)
src/live_effects/lpe-curvestitch.cpp
src/live_effects/lpe-curvestitch.h
src/live_effects/parameter/bool.h

index b0e8dc8f7106cc0333159a46e3f9339ea7a58120..f595a9553cd07b62cd2905d9fbdda9ff7fad9d0c 100644 (file)
@@ -40,12 +40,14 @@ LPECurveStitch::LPECurveStitch(LivePathEffectObject *lpeobject) :
     strokepath(_("Stroke path"), _("The path that will be stroked, whatever, think of good text here."), "strokepath", &wr, this, "M0,0 L1,0"),\r
     nrofpaths(_("Nr of paths"), _("The number of paths that will be generated."), "count", &wr, this, 5),\r
     startpoint_variation(_("Startpoint variation"), _("..."), "startpoint_variation", &wr, this, 0),\r
-    endpoint_variation(_("Endpoint variation"), _("..."), "endpoint_variation", &wr, this, 0)\r
+    endpoint_variation(_("Endpoint variation"), _("..."), "endpoint_variation", &wr, this, 0),\r
+    scale_y(_("Scale stroke y"), _("Scale the height of the stroke path with its length"), "scale_stroke_y", &wr, this, false)\r
 {\r
     registerParameter( dynamic_cast<Parameter *>(&nrofpaths) );\r
     registerParameter( dynamic_cast<Parameter *>(&startpoint_variation) );\r
     registerParameter( dynamic_cast<Parameter *>(&endpoint_variation) );\r
     registerParameter( dynamic_cast<Parameter *>(&strokepath) );\r
+    registerParameter( dynamic_cast<Parameter *>(&scale_y) );\r
 \r
     nrofpaths.param_make_integer();\r
     nrofpaths.param_set_range(2, NR_HUGE);\r
@@ -90,9 +92,11 @@ LPECurveStitch::doEffect (std::vector<Geom::Path> & path_in)
     \r
             Matrix transform;\r
             transform.setXAxis( (end-start) / scaling );\r
-            transform.setYAxis( rot90(unit_vector(end-start)));\r
+            gdouble scaling_y = scale_y.get_value() ? L2(end-start)/scaling : 1.0;\r
+            transform.setYAxis( rot90(unit_vector(end-start)) * scaling_y);\r
             transform.setTranslation( start );\r
             Piecewise<D2<SBasis> > pwd2_out = (strokepath-stroke_origin) * transform;\r
+            // add stuff to one big pw<d2<sbasis> > and then outside the loop convert to path?\r
             std::vector<Path> result = Geom::path_from_piecewise(pwd2_out, LPE_CONVERSION_TOLERANCE);\r
             path_out[i] = result[0];\r
             tA += incrementA;\r
index 1853e378ffe49d4e7c7369a62c071202d25128f5..571996a7cc89f770c157deb6757a9193ec960de4 100644 (file)
@@ -17,6 +17,7 @@
 #include "live_effects/effect.h"\r
 #include "live_effects/parameter/path.h"\r
 #include "live_effects/parameter/parameter.h"\r
+#include "live_effects/parameter/bool.h"\r
 \r
 namespace Inkscape {\r
 namespace LivePathEffect {\r
@@ -33,6 +34,7 @@ private:
     ScalarParam nrofpaths;\r
     ScalarParam startpoint_variation;\r
     ScalarParam endpoint_variation;\r
+    BoolParam scale_y;\r
 \r
     LPECurveStitch(const LPECurveStitch&);\r
     LPECurveStitch& operator=(const LPECurveStitch&);\r
index cf8c9c94d4302c34a3eeeacd6d5d00043d856fc5..24c10fb3b3f24b272f8fc9893ef1cc4bdc770996 100644 (file)
@@ -39,6 +39,8 @@ public:
     void param_setValue(bool newvalue);\r
     void param_set_default();\r
 \r
+    bool get_value() { return value; };\r
+\r
 private:\r
     BoolParam(const BoolParam&);\r
     BoolParam& operator=(const BoolParam&);\r