Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-core / tags / stable / src / modules / mod_filter / halftone.cpp
index 1855dc4..8e8ba9e 100644 (file)
@@ -1,20 +1,22 @@
-/* === S I N F G =========================================================== */
+/* === S Y N F I G ========================================================= */
 /*!    \file halftone.cpp
 **     \brief blehh
 **
-**     $Id: halftone.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $
+**     $Id$
 **
 **     \legal
-**     Copyright (c) 2002 Robert B. Quattlebaum Jr.
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2008 Chris Moore
 **
-**     This software and associated documentation
-**     are CONFIDENTIAL and PROPRIETARY property of
-**     the above-mentioned copyright holder.
+**     This package is free software; you can redistribute it and/or
+**     modify it under the terms of the GNU General Public License as
+**     published by the Free Software Foundation; either version 2 of
+**     the License, or (at your option) any later version.
 **
-**     You may not copy, print, publish, or in any
-**     other way distribute this software without
-**     a prior written agreement with
-**     the copyright holder.
+**     This package is distributed in the hope that it will be useful,
+**     but WITHOUT ANY WARRANTY; without even the implied warranty of
+**     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+**     General Public License for more details.
 **     \endlegal
 */
 /* ========================================================================= */
@@ -34,7 +36,7 @@
 
 /* === M A C R O S ========================================================= */
 
-using namespace sinfg;
+using namespace synfig;
 using namespace std;
 using namespace etl;
 
@@ -51,14 +53,14 @@ float
 Halftone::operator()(const Point &point, const float& luma, float supersample)const
 {
        float halftone(mask(point));
-       
+
        if(supersample>=0.5f)
                supersample=0.4999999999f;
-       
+
        halftone=(halftone-0.5f)*(1.0f-supersample*2.0f)+0.5f;
-       
+
        const float diff(halftone-luma);
-       
+
        if(supersample)
        {
                const float amount(diff/(supersample*2.0f)+0.5f);
@@ -82,17 +84,17 @@ Halftone::operator()(const Point &point, const float& luma, float supersample)co
 }
 
 float
-Halftone::mask(sinfg::Point point)const
+Halftone::mask(synfig::Point point)const
 {
        float radius1;
        float radius2;
-       
-       point-=offset;
+
+       point-=origin;
 
        {
                const float     a(Angle::sin(-angle).get()),    b(Angle::cos(-angle).get());
                const float     u(point[0]),v(point[1]);
-       
+
                point[0]=b*u-a*v;
                point[1]=a*u+b*v;
        }
@@ -108,7 +110,7 @@ Halftone::mask(sinfg::Point point)const
                x*=2;
                return x;
        }
-       
+
        {
                Point pnt(fmod(point[0],size[0]),fmod(point[1],size[1]));
                while(pnt[0]<0)pnt[0]+=abs(size[0]);
@@ -117,13 +119,13 @@ Halftone::mask(sinfg::Point point)const
                pnt*=2.0;
                pnt[0]/=size[0];
                pnt[1]/=size[1];
-               
+
                radius1=pnt.mag()/SQRT2;
                radius1*=radius1;
        }
        if(type==TYPE_DARKONLIGHT || type== TYPE_LIGHTONDARK)
                return radius1;
-       
+
        {
                Point pnt(fmod(point[0]+size[0]*0.5,size[0]),fmod(point[1]+size[0]*0.5,size[1]));
                while(pnt[0]<0)pnt[0]+=abs(size[0]);
@@ -132,11 +134,11 @@ Halftone::mask(sinfg::Point point)const
                pnt*=2.0;
                pnt[0]/=size[0];
                pnt[1]/=size[1];
-               
+
                radius2=pnt.mag()/SQRT2;
                radius2*=radius2;
        }
-       
+
        if(type==TYPE_DIAMOND)
        {
                //return (radius1+(1.0f-radius2))*0.5;
@@ -145,19 +147,19 @@ Halftone::mask(sinfg::Point point)const
                x-=0.5;
                x*=2.0;
                if(x<0)x=-sqrt(-x);else x=sqrt(x);
-               x*=1.01f;       
+               x*=1.01f;
                x/=2.0;
                x+=0.5;
                return x;
        }
-       
+
        if(type==TYPE_SYMMETRIC)
        {
                float x(((radius2-radius1)*((radius1+(1.0f-radius2))*0.5)+radius1)*2.0f);
                x-=0.5;
                x*=2.0;
                if(x<0)x=-sqrt(-x);else x=sqrt(x);
-               x*=1.01f;       
+               x*=1.01f;
                x/=2.0;
                x+=0.5;
                return x;