Rearranged "if (!x) a; else b;" to "if (x) b; else a;". Added a couple of comments...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Mon, 10 Sep 2007 23:00:31 +0000 (23:00 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Mon, 10 Sep 2007 23:00:31 +0000 (23:00 +0000)
git-svn-id: http://svn.voria.com/code@652 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-core/trunk/src/modules/mod_gradient/curvegradient.cpp

index 7d48f05..2dde697 100644 (file)
@@ -285,18 +285,18 @@ CurveGradient::color_func(const Point &point_, int quality, float supersample)co
                  else if(quality<=2)search_iterations=10;
                  else if(quality<=4)search_iterations=8;
                */
-               if(!perpendicular)
+               if(perpendicular)
+               {
+                       if(quality>7)
+                               search_iterations=4;
+               }
+               else
                {
                        if(quality<=6)search_iterations=7;
                        else if(quality<=7)search_iterations=6;
                        else if(quality<=8)search_iterations=5;
                        else search_iterations=4;
                }
-               else
-               {
-                       if(quality>7)
-                               search_iterations=4;
-               }
 
                // Figure out the closest point on the curve
                if (fast)
@@ -304,8 +304,8 @@ CurveGradient::color_func(const Point &point_, int quality, float supersample)co
 
 
                // Calculate our values
-               p1=curve(t);
-               tangent=deriv(t).norm();
+               p1=curve(t);                    // the closest point on the curve
+               tangent=deriv(t).norm(); // the unit tangent at that point
 
                if(perpendicular)
                {
@@ -314,22 +314,11 @@ CurveGradient::color_func(const Point &point_, int quality, float supersample)co
                        tangent=-tangent.perp();
                }
                else
-               {
+                       // the width of the bline at the closest point on the curve
                        thickness=(next->get_width()-iter->get_width())*t+iter->get_width();
-               }
-               //}
        }
 
-       if(!perpendicular)
-       {
-               diff=tangent.perp()*thickness*width;
-               p1-=diff*0.5;
-               const Real mag(diff.inv_mag());
-               supersample=supersample*mag;
-               diff*=mag*mag;
-               dist=((point_-offset)*diff-p1*diff);
-       }
-       else
+       if(perpendicular)
        {
                if(quality>7)
                {
@@ -350,6 +339,15 @@ CurveGradient::color_func(const Point &point_, int quality, float supersample)co
                        dist=((point_-offset)*diff-p1*diff);
                }
        }
+       else
+       {
+               diff=tangent.perp()*thickness*width;
+               p1-=diff*0.5;
+               const Real mag(diff.inv_mag());
+               supersample=supersample*mag;
+               diff*=mag*mag;
+               dist=((point_-offset)*diff-p1*diff);
+       }
 
        if(loop)
                dist-=floor(dist);