Code

lpe-vonkoch: added checkbox to restrict to (orientation preserving or not) similarity...
authorjfbarraud <jfbarraud@users.sourceforge.net>
Wed, 17 Sep 2008 22:38:48 +0000 (22:38 +0000)
committerjfbarraud <jfbarraud@users.sourceforge.net>
Wed, 17 Sep 2008 22:38:48 +0000 (22:38 +0000)
src/live_effects/lpe-vonkoch.cpp
src/live_effects/lpe-vonkoch.h

index bc86e4daae42dd5df00594cd906c4bc7fc4cd216..5c77801c8ee0d219bef57e4d008c8821f30f8263 100644 (file)
@@ -50,12 +50,14 @@ LPEVonKoch::LPEVonKoch(LivePathEffectObject *lpeobject) :
     generator(_("Generating path"), _("Path whos segments define the fractal"), "generator", &wr, this, "M0,0 L3,0 M0,1 L1,1 M 2,1 L3,1"),
     drawall(_("Draw all generations"), _("If unchecked, draw only the last generation"), "drawall", &wr, this, true),
     reftype(_("Reference"), _("Generating path segments define transforms in reference to bbox or last segment"), "reftype", VonKochRefTypeConverter, &wr, this, VKREF_BBOX),
+    similar_only(_("Use uniform scale/rotation only"), _("If off, 2segments component of generating path can be used to define a general rtansform. If on, they only affect the orientation preserving/reversing of the transform."), "similar_only", &wr, this, false),
     maxComplexity(_("Max complexity"), _("Disable effect if the output is too complex"), "maxComplexity", &wr, this, 1000)
 {
     registerParameter( dynamic_cast<Parameter *>(&generator) );
     registerParameter( dynamic_cast<Parameter *>(&nbgenerations) );
     registerParameter( dynamic_cast<Parameter *>(&drawall) );
     registerParameter( dynamic_cast<Parameter *>(&reftype) );
+    registerParameter( dynamic_cast<Parameter *>(&similar_only) );
     registerParameter( dynamic_cast<Parameter *>(&maxComplexity) );
 
     nbgenerations.param_make_integer();
@@ -107,6 +109,11 @@ LPEVonKoch::doEffect_path (std::vector<Geom::Path> const & path_in)
             Point p = generating_path[i].pointAt(1);
             Point u = generating_path[i].pointAt(2)-p;
             Point v = p-generating_path[i].pointAt(0);
+            if (similar_only){
+                int sign = (u[X]*v[Y]-u[Y]*v[X]>=0?1:-1);
+                v[X] = -u[Y]*sign;
+                v[Y] =  u[X]*sign;
+            }
             m = Matrix(u[X], u[Y],v[X], v[Y], p[X], p[Y]);
             m = m0*m;
             transforms.push_back(m);
index 4909b87303af62f944d22ae1c52eccd014b1c299..8b7d0c62e5314bd855690852c41887f5d59ba899 100644 (file)
@@ -52,6 +52,7 @@ public:
 private:
     ScalarParam  nbgenerations;
     VonKochPathParam    generator;
+    BoolParam    similar_only;
     BoolParam    drawall;
     EnumParam<VonKochRefType> reftype;
     ScalarParam  maxComplexity;