Remove .gitignore do nothing is ignored.
[synfig.git] / synfig-core / trunk / src / synfig / gradient.cpp
index ed5f9b9..00f67b0 100644 (file)
@@ -6,6 +6,7 @@
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007 Chris Moore
 **
 **     This package is free software; you can redistribute it and/or
 **     modify it under the terms of the GNU General Public License as
@@ -140,11 +141,11 @@ supersample_helper(const synfig::Gradient::CPoint &color1, const synfig::Gradien
 //     assert(0);
 }
 
-static void show_gradient(const Gradient::CPointList x) {
+static void show_gradient(const Gradient::CPointList x)
+{
        int i = 0;
-       for (Gradient::const_iterator iter = x.begin(); iter != x.end(); iter++) {
+       for (Gradient::const_iterator iter = x.begin(); iter != x.end(); iter++)
                printf("%3d : %.3f %s\n", i++, (*iter).pos, (*iter).color.get_string().c_str());
-       }
 }
 
 Gradient &
@@ -164,7 +165,6 @@ synfig::Gradient::operator+=(const Gradient &rhs)
        // if there are cpoints in both gradients run through both until one runs out
        if (iter1 != end() && iter2 != rhs.end())
                while(true)
-               {
                        // if the left one has the first cpoint
                        if (left.pos < right.pos)
                        {
@@ -189,24 +189,21 @@ synfig::Gradient::operator+=(const Gradient &rhs)
                                int tpos1 = pos1, tpos2 = pos2;
                                // skip past all cpoints at the same position
                                for(left_same = ++iter1; iter1 != end() && (*iter1).pos == left.pos; iter1++, pos1++)
-                               {
                                        if (print) printf("skipping past pos %d in left\n", pos1);
-                               }
                                for(right_same = ++iter2; iter2 != rhs.end() && (*iter2).pos == right.pos; iter2++, pos2++)
-                               {
                                        if (print) printf("skipping past pos %d in right\n", pos2);
-                               }
-                               
+
                                // if there is only one cpoint at this position in each gradient,
                                // there's only one corresponding cpoint in the sum
-                               if (iter1 == left_same && iter2 == right_same) {
+                               if (iter1 == left_same && iter2 == right_same)
+                               {
                                        if (print) printf("two singles at left %d and right %d\n", pos1++, pos2++);
                                        ret.push_back(CPoint(left.pos, left.color + right.color));
                                }
                                // otherwise we sum the first in each, and the last in each
                                else
                                {
-                                       if (print) printf("[copying %d from left %d and %d from right %d at %.2f]\n", iter1-left_same+1, tpos1, iter2-right_same+1, tpos2, left.pos);
+                                       if (print) printf("[copying %ld from left %d and %ld from right %d at %.2f]\n", iter1-left_same+1, tpos1, iter2-right_same+1, tpos2, left.pos);
                                        // merge the front two cpoints
                                        if (print) printf("  copy front from left %d right %d\n", tpos1++, tpos2++);
                                        ret.push_back(CPoint(left.pos, left.color + right.color));
@@ -242,7 +239,6 @@ synfig::Gradient::operator+=(const Gradient &rhs)
                                right = *iter2;
                                if (iter1 == end()) break;
                        }
-               }
 
        // one of the gradients has run out of points
        // does the left one have points left?
@@ -324,7 +320,7 @@ synfig::Gradient::operator()(const Real &x,float supersample)const
        const_iterator iter,next;
 
        /*
-       //optimizize...
+       //optimize...
        Real    left = x-supersample/2, right = x+supersample/2;
 
        if(left < front().pos) left = front().pos;
@@ -353,7 +349,7 @@ synfig::Gradient::operator()(const Real &x,float supersample)const
                //return Color::blend(iterr->color,iterl->color,lambda,Color::BLEND_STRAIGHT);
        }else
        {
-               //itegration madness
+               //integration madness
                const_iterator i = iterl, ie = iterr+1;
                Real wlast = left;
 
@@ -409,7 +405,7 @@ synfig::Gradient::operator()(const Real &x,float supersample)const
        //! using a binary search.
        for(;iter<end();iter=next++)
        {
-               if(next==end() || x>=iter->pos &&  x<next->pos && iter->pos!=next->pos)
+               if(next==end() || (x>=iter->pos && x<next->pos && iter->pos!=next->pos))
                {
                        // If the supersample region falls square in between
                        // two CPoints, then we don't have to do anything special.