1 /* === S Y N F I G ========================================================= */
3 ** \brief Template Header
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
34 #include <synfig/string.h>
35 #include <synfig/time.h>
36 #include <synfig/context.h>
37 #include <synfig/paramdesc.h>
38 #include <synfig/renddesc.h>
39 #include <synfig/surface.h>
40 #include <synfig/value.h>
41 #include <synfig/valuenode.h>
42 #include <synfig/segment.h>
46 using namespace synfig;
50 /* === M A C R O S ========================================================= */
52 /* === G L O B A L S ======================================================= */
54 SYNFIG_LAYER_INIT(LumaKey);
55 SYNFIG_LAYER_SET_NAME(LumaKey,"lumakey");
56 SYNFIG_LAYER_SET_LOCAL_NAME(LumaKey,_("LumaKey"));
57 SYNFIG_LAYER_SET_CATEGORY(LumaKey,_("Filters"));
58 SYNFIG_LAYER_SET_VERSION(LumaKey,"0.1");
59 SYNFIG_LAYER_SET_CVS_ID(LumaKey,"$Id$");
61 /* === P R O C E D U R E S ================================================= */
63 /* === M E T H O D S ======================================================= */
66 Layer_Composite (1.0,Color::BLEND_STRAIGHT)
68 set_blend_method(Color::BLEND_STRAIGHT);
73 LumaKey::set_param(const String ¶m, const ValueBase &value)
75 return Layer_Composite::set_param(param,value);
79 LumaKey::get_param(const String ¶m)const
84 return Layer_Composite::get_param(param);
88 LumaKey::get_param_vocab()const
90 Layer::Vocab ret(Layer_Composite::get_param_vocab());
92 /* ret.push_back(ParamDesc("color")
93 .set_local_name(_("Color"))
94 .set_description(_("Color of checkers"))
96 ret.push_back(ParamDesc("pos")
97 .set_local_name(_("Offset"))
99 ret.push_back(ParamDesc("size")
100 .set_local_name(_("Size"))
101 .set_description(_("Size of checkers"))
108 synfig::Layer::Handle
109 LumaKey::hit_check(synfig::Context context, const synfig::Point &getpos)const
111 return context.hit_check(getpos);
115 LumaKey::get_color(Context context, const Point &getpos)const
117 const Color color(context.get_color(getpos));
119 if(get_amount()==0.0)
123 ret.set_a(ret.get_y()*ret.get_a());
126 if(get_amount()==1.0 && get_blend_method()==Color::BLEND_STRAIGHT)
129 return Color::blend(ret,color,get_amount(),get_blend_method());
133 LumaKey::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
135 SuperCallback supercb(cb,0,9500,10000);
137 if(!context.accelerated_render(surface,quality,renddesc,&supercb))
142 Surface::pen pen(surface->begin());
144 for(y=0;y<renddesc.get_h();y++,pen.inc_y(),pen.dec_x(x))
145 for(x=0;x<renddesc.get_w();x++,pen.inc_x())
147 Color tmp(pen.get_value());
148 tmp.set_a(tmp.get_y()*tmp.get_a());
153 // Mark our progress as finished
154 if(cb && !cb->amount_complete(10000,10000))
161 LumaKey::get_bounding_rect(Context context)const
166 return context.get_full_bounding_rect();