1 /* === S Y N F I G ========================================================= */
2 /*! \file layer_solidcolor.cpp
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 ======================================================= */
32 #include "layer_solidcolor.h"
36 #include "paramdesc.h"
40 #include "valuenode.h"
44 /* === U S I N G =========================================================== */
48 using namespace synfig;
50 /* === G L O B A L S ======================================================= */
52 SYNFIG_LAYER_INIT(Layer_SolidColor);
53 SYNFIG_LAYER_SET_NAME(Layer_SolidColor,"solid_color");
54 SYNFIG_LAYER_SET_LOCAL_NAME(Layer_SolidColor,_("Solid Color"));
55 SYNFIG_LAYER_SET_CATEGORY(Layer_SolidColor,_("Geometry"));
56 SYNFIG_LAYER_SET_VERSION(Layer_SolidColor,"0.1");
57 SYNFIG_LAYER_SET_CVS_ID(Layer_SolidColor,"$Id$");
59 /* === P R O C E D U R E S ================================================= */
61 /* === M E T H O D S ======================================================= */
63 /* === E N T R Y P O I N T ================================================= */
65 Layer_SolidColor::Layer_SolidColor():
66 Layer_Composite(1.0,Color::BLEND_STRAIGHT),
72 Layer_SolidColor::set_param(const String & param, const ValueBase &value)
76 return Layer_Composite::set_param(param,value);
80 Layer_SolidColor::get_param(const String ¶m)const
87 return Layer_Composite::get_param(param);
91 Layer_SolidColor::get_param_vocab()const
93 Layer::Vocab ret(Layer_Composite::get_param_vocab());
95 ret.push_back(ParamDesc("color")
96 .set_local_name(_("Color"))
102 synfig::Layer::Handle
103 Layer_SolidColor::hit_check(synfig::Context context, const synfig::Point &point)const
105 if(get_blend_method()==Color::BLEND_STRAIGHT && get_amount()>=0.5)
106 return const_cast<Layer_SolidColor*>(this);
108 if(get_blend_method()==Color::BLEND_COMPOSITE && get_amount()*color.get_a()>=0.5)
109 return const_cast<Layer_SolidColor*>(this);
111 Layer::Handle layer(context.hit_check(point));
113 return layer?layer:const_cast<Layer_SolidColor*>(this);
117 Layer_SolidColor::get_color(Context context, const Point &pos)const
119 if(get_amount()==1.0 && get_blend_method()==Color::BLEND_STRAIGHT)
122 return Color::blend(color,context.get_color(pos),get_amount(),get_blend_method());
126 Layer_SolidColor::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
128 if(get_amount()==1.0 && get_blend_method()==Color::BLEND_STRAIGHT)
130 // Mark our progress as starting
131 if(cb && !cb->amount_complete(0,1000))
134 surface->set_wh(renddesc.get_w(),renddesc.get_h());
135 surface->fill(color);
137 // Mark our progress as finished
138 if(cb && !cb->amount_complete(1000,1000))
144 SuperCallback supercb(cb,0,9500,10000);
146 if(!context.accelerated_render(surface,quality,renddesc,&supercb))
151 Surface::alpha_pen apen(surface->begin());
153 apen.set_value(color);
154 apen.set_alpha(get_amount());
155 apen.set_blend_method(get_blend_method());
157 for(y=0;y<renddesc.get_h();y++,apen.inc_y(),apen.dec_x(x))
158 for(x=0;x<renddesc.get_w();x++,apen.inc_x())
161 // Mark our progress as finished
162 if(cb && !cb->amount_complete(10000,10000))