Remove .gitignore do nothing is ignored.
[synfig.git] / synfig-core / trunk / src / modules / mod_filter / halftone3.cpp
index 62b76d7..a2a4283 100644 (file)
@@ -1,20 +1,22 @@
 /* === S Y N F I G ========================================================= */
 /*!    \file halftone3.cpp
-**     \brief blehh
+**     \brief Implementation of the "Halftone 3" layer
 **
-**     $Id: halftone3.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) 2007-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
 */
 /* ========================================================================= */
@@ -52,10 +54,10 @@ using namespace etl;
 
 SYNFIG_LAYER_INIT(Halftone3);
 SYNFIG_LAYER_SET_NAME(Halftone3,"halftone3");
-SYNFIG_LAYER_SET_LOCAL_NAME(Halftone3,_("Halftone3"));
-SYNFIG_LAYER_SET_CATEGORY(Halftone3,_("Filters"));
+SYNFIG_LAYER_SET_LOCAL_NAME(Halftone3,N_("Halftone 3"));
+SYNFIG_LAYER_SET_CATEGORY(Halftone3,N_("Filters"));
 SYNFIG_LAYER_SET_VERSION(Halftone3,"0.0");
-SYNFIG_LAYER_SET_CVS_ID(Halftone3,"$Id: halftone3.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $");
+SYNFIG_LAYER_SET_CVS_ID(Halftone3,"$Id$");
 
 /* === P R O C E D U R E S ================================================= */
 
@@ -73,7 +75,7 @@ Halftone3::Halftone3()
        {
                tone[i].size=size;
                tone[i].type=type;
-               tone[i].offset=(synfig::Point(0,0));
+               tone[i].origin=(synfig::Point(0,0));
                tone[i].angle=Angle::deg(30.0)*(float)i;
        }
 
@@ -91,7 +93,7 @@ Halftone3::Halftone3()
                color[1]=Color::green();
                color[2]=Color::blue();
        }
-               
+
        set_blend_method(Color::BLEND_STRAIGHT);
 
        for(int i=0;i<3;i++)
@@ -109,10 +111,10 @@ Halftone3::sync()
                tone[i].size=size;
                tone[i].type=type;
        }
-       
+
 #define matrix inverse_matrix
        //float matrix[3][3];
-       
+
        if(subtractive)
        {
                for(int i=0;i<3;i++)
@@ -153,38 +155,38 @@ Halftone3::sync()
        }
 #undef matrix
 
-       
-       
+
+
 #if 0
        // Insert guass-jordan elimination code here
        int k=0,i=0,j=0,z_size=3;
 #define A inverse_matrix
-       
-       for (k=0;k<z_size;k++)   
-  // the pivot element 
-    { A[k][k]= -1/A[k][k];   
+
+       for (k=0;k<z_size;k++)
+  // the pivot element
+    { A[k][k]= -1/A[k][k];
+
   //the pivot column
-     for (i=0;i<z_size;i++)             
+     for (i=0;i<z_size;i++)
          if (i!=k) A[i][k]*=A[k][k];
 
  //elements not in a pivot row or column
      for (i=0;i<z_size;i++)
-        if (i!=k) 
+        if (i!=k)
             for (j=0;j<z_size;j++)
                       if (j!=k)
                           A[i][j]+=A[i][k]*A[k][j];
 
  //elements in a pivot row
     for (i=0;i<z_size;i++)
-       if (i!=k) 
+       if (i!=k)
             A[k][i]*=A[k][k];
    }
 
  //change sign
    for (i=0;i<z_size;i++)        /*reverse sign*/
      for (j=0;j<z_size;j++)
-        A[i][j]=-A[i][j];      
+        A[i][j]=-A[i][j];
 #undef A
 #endif
 }
@@ -195,8 +197,8 @@ Halftone3::color_func(const Point &point, float supersample,const Color& in_colo
        Color halfcolor;
 
        float chan[3];
-       
-       
+
+
        if(subtractive)
        {
                chan[0]=inverse_matrix[0][0]*(1.0f-in_color.get_r())+inverse_matrix[0][1]*(1.0f-in_color.get_g())+inverse_matrix[0][2]*(1.0f-in_color.get_b());
@@ -207,7 +209,7 @@ Halftone3::color_func(const Point &point, float supersample,const Color& in_colo
                halfcolor-=(~color[0])*tone[0](point,chan[0],supersample);
                halfcolor-=(~color[1])*tone[1](point,chan[1],supersample);
                halfcolor-=(~color[2])*tone[2](point,chan[2],supersample);
-       
+
                halfcolor.set_a(in_color.get_a());
        }
        else
@@ -220,7 +222,7 @@ Halftone3::color_func(const Point &point, float supersample,const Color& in_colo
                halfcolor+=color[0]*tone[0](point,chan[0],supersample);
                halfcolor+=color[1]*tone[1](point,chan[1],supersample);
                halfcolor+=color[2]*tone[2](point,chan[2],supersample);
-       
+
                halfcolor.set_a(in_color.get_a());
        }
 
@@ -228,13 +230,13 @@ Halftone3::color_func(const Point &point, float supersample,const Color& in_colo
 }
 
 inline float
-Halftone3::calc_supersample(const synfig::Point &x, float pw,float ph)const
+Halftone3::calc_supersample(const synfig::Point &/*x*/, float pw,float /*ph*/)const
 {
        return abs(pw/(tone[0].size).mag());
 }
 
 synfig::Layer::Handle
-Halftone3::hit_check(synfig::Context context, const synfig::Point &point)const
+Halftone3::hit_check(synfig::Context /*context*/, const synfig::Point &/*point*/)const
 {
        return const_cast<Halftone3*>(this);
 }
@@ -248,19 +250,23 @@ Halftone3::set_param(const String & param, const ValueBase &value)
        IMPORT_PLUS(color[0],sync());
        IMPORT_PLUS(color[1],sync());
        IMPORT_PLUS(color[2],sync());
-       
+
        IMPORT_PLUS(subtractive,sync());
-       
+
        IMPORT(tone[0].angle);
-       IMPORT(tone[0].offset);
+       IMPORT(tone[0].origin);
 
        IMPORT(tone[1].angle);
-       IMPORT(tone[1].offset);
+       IMPORT(tone[1].origin);
 
        IMPORT(tone[2].angle);
-       IMPORT(tone[2].offset);
-       
-       return Layer_Composite::set_param(param,value); 
+       IMPORT(tone[2].origin);
+
+       IMPORT_AS(tone[0].origin,"tone[0].offset");
+       IMPORT_AS(tone[1].origin,"tone[1].offset");
+       IMPORT_AS(tone[2].origin,"tone[2].offset");
+
+       return Layer_Composite::set_param(param,value);
 }
 
 ValueBase
@@ -274,20 +280,20 @@ Halftone3::get_param(const String & param)const
        EXPORT(color[2]);
 
        EXPORT(subtractive);
-       
+
        EXPORT(tone[0].angle);
-       EXPORT(tone[0].offset);
+       EXPORT(tone[0].origin);
 
        EXPORT(tone[1].angle);
-       EXPORT(tone[1].offset);
+       EXPORT(tone[1].origin);
 
        EXPORT(tone[2].angle);
-       EXPORT(tone[2].offset);
+       EXPORT(tone[2].origin);
 
        EXPORT_NAME();
        EXPORT_VERSION();
-               
-       return Layer_Composite::get_param(param);       
+
+       return Layer_Composite::get_param(param);
 }
 
 Layer::Vocab
@@ -310,25 +316,25 @@ Halftone3::get_param_vocab()const
        ret.push_back(ParamDesc("subtractive")
                .set_local_name(_("Subtractive Flag"))
        );
-       
+
        for(int i=0;i<3;i++)
        {
                String chan_name(strprintf("Chan%d",i));
-               
+
                ret.push_back(ParamDesc(strprintf("color[%d]",i))
                        .set_local_name(chan_name+_(" Color"))
                );
 
-               ret.push_back(ParamDesc(strprintf("tone[%d].offset",i))
-                       .set_local_name(chan_name+_(" Mask Offset"))
+               ret.push_back(ParamDesc(strprintf("tone[%d].origin",i))
+                       .set_local_name(chan_name+_(" Mask Origin"))
                        .set_is_distance()
                );
                ret.push_back(ParamDesc(strprintf("tone[%d].angle",i))
                        .set_local_name(chan_name+_(" Mask Angle"))
-                       .set_origin(strprintf("tone[%d].offset",i))
+                       .set_origin(strprintf("tone[%d].origin",i))
                );
        }
-       
+
        return ret;
 }
 
@@ -353,7 +359,7 @@ Halftone3::accelerated_render(Context context,Surface *surface,int quality, cons
                return false;
        if(get_amount()==0)
                return true;
-               
+
        const Real pw(renddesc.get_pw()),ph(renddesc.get_ph());
        const Point tl(renddesc.get_tl());
        const int w(surface->get_w());
@@ -363,7 +369,7 @@ Halftone3::accelerated_render(Context context,Surface *surface,int quality, cons
        Surface::pen pen(surface->begin());
        Point pos;
        int x,y;
-       
+
        if(is_solid_color())
        {
                for(y=0,pos[1]=tl[1];y<h;y++,pen.inc_y(),pen.dec_x(x),pos[1]+=ph)
@@ -393,7 +399,7 @@ Halftone3::accelerated_render(Context context,Surface *surface,int quality, cons
                                        )
                                );
        }
-       
+
        // Mark our progress as finished
        if(cb && !cb->amount_complete(10000,10000))
                return false;