1 /* === S Y N F I G ========================================================= */
2 /*! \file simplecircle.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 <synfig/string.h>
33 #include <synfig/time.h>
34 #include <synfig/context.h>
35 #include <synfig/paramdesc.h>
36 #include <synfig/renddesc.h>
37 #include <synfig/surface.h>
38 #include <synfig/value.h>
39 #include <synfig/valuenode.h>
41 #include "simplecircle.h"
45 /* === U S I N G =========================================================== */
49 using namespace synfig;
51 /* === G L O B A L S ======================================================= */
53 SYNFIG_LAYER_INIT(SimpleCircle);
54 SYNFIG_LAYER_SET_NAME(SimpleCircle,"simple_circle");
55 SYNFIG_LAYER_SET_LOCAL_NAME(SimpleCircle,_("Simple Circle"));
56 SYNFIG_LAYER_SET_CATEGORY(SimpleCircle,_("Do Not Use"));
57 SYNFIG_LAYER_SET_VERSION(SimpleCircle,"0.1");
58 SYNFIG_LAYER_SET_CVS_ID(SimpleCircle,"$Id$");
60 /* === P R O C E D U R E S ================================================= */
62 /* === M E T H O D S ======================================================= */
64 /* === E N T R Y P O I N T ================================================= */
66 SimpleCircle::SimpleCircle():
67 Layer_Composite(1.0,Color::BLEND_STRAIGHT),
68 color(Color::black()),
75 SimpleCircle::set_param(const String & param, const ValueBase &value)
81 return Layer_Composite::set_param(param,value);
85 SimpleCircle::get_param(const String ¶m)const
94 return Layer_Composite::get_param(param);
98 SimpleCircle::get_param_vocab()const
100 Layer::Vocab ret(Layer_Composite::get_param_vocab());
102 ret.push_back(ParamDesc("color")
103 .set_local_name(_("Color"))
106 ret.push_back(ParamDesc("center")
107 .set_local_name(_("Center"))
110 ret.push_back(ParamDesc("radius")
111 .set_local_name(_("Radius"))
112 .set_description(_("This is the radius of the circle"))
113 .set_origin("center")
120 SimpleCircle::get_color(Context context, const Point &pos)const
123 if((pos-center).mag()<radius)
125 if(get_amount()==1.0 && get_blend_method()==Color::BLEND_STRAIGHT)
128 return Color::blend(color,context.get_color(pos),get_amount(),get_blend_method());
131 return context.get_color(pos);
134 synfig::Layer::Handle
135 SimpleCircle::hit_check(synfig::Context context, const synfig::Point &pos)const
137 if((pos-center).mag()<radius)
138 return const_cast<SimpleCircle*>(this);
140 return context.hit_check(pos);
145 SimpleCircle::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
147 if(get_amount()==1.0 && get_blend_method()==Color::BLEND_STRAIGHT)
149 // Mark our progress as starting
150 if(cb && !cb->amount_complete(0,1000))
153 surface->set_wh(renddesc.get_w(),renddesc.get_h());
154 surface->fill(color);
156 // Mark our progress as finished
157 if(cb && !cb->amount_complete(1000,1000))
163 SuperCallback supercb(cb,0,9500,10000);
165 if(!context.accelerated_render(surface,quality,renddesc,&supercb))
170 Surface::alpha_pen apen(surface->begin());
172 apen.set_value(color);
173 apen.set_alpha(get_amount());
174 apen.set_blend_method(get_blend_method());
176 for(y=0;y<renddesc.get_h();y++,apen.inc_y(),apen.dec_x(x))
177 for(x=0;x<renddesc.get_w();x++,apen.inc_x())
180 // Mark our progress as finished
181 if(cb && !cb->amount_complete(10000,10000))