/* === 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 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
*/
/* ========================================================================= */
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 ================================================= */
color[1]=Color::green();
color[2]=Color::blue();
}
-
+
set_blend_method(Color::BLEND_STRAIGHT);
for(int i=0;i<3;i++)
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++)
}
#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
}
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());
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
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());
}
}
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);
}
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[2].angle);
IMPORT(tone[2].offset);
-
- return Layer_Composite::set_param(param,value);
+
+ return Layer_Composite::set_param(param,value);
}
ValueBase
EXPORT(color[2]);
EXPORT(subtractive);
-
+
EXPORT(tone[0].angle);
EXPORT(tone[0].offset);
EXPORT_NAME();
EXPORT_VERSION();
-
- return Layer_Composite::get_param(param);
+
+ return Layer_Composite::get_param(param);
}
Layer::Vocab
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"))
);
.set_origin(strprintf("tone[%d].offset",i))
);
}
-
+
return ret;
}
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());
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)
)
);
}
-
+
// Mark our progress as finished
if(cb && !cb->amount_complete(10000,10000))
return false;