1 /* === S I N F G =========================================================== */
2 /*! \file layer_solidcolor.cpp
3 ** \brief Template Header
5 ** $Id: simplecircle.cpp,v 1.1.1.1 2005/01/04 01:23:09 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === H E A D E R S ======================================================= */
31 #include <sinfg/string.h>
32 #include <sinfg/time.h>
33 #include <sinfg/context.h>
34 #include <sinfg/paramdesc.h>
35 #include <sinfg/renddesc.h>
36 #include <sinfg/surface.h>
37 #include <sinfg/value.h>
38 #include <sinfg/valuenode.h>
40 #include "simplecircle.h"
44 /* === U S I N G =========================================================== */
48 using namespace sinfg;
50 /* === G L O B A L S ======================================================= */
52 SINFG_LAYER_INIT(SimpleCircle);
53 SINFG_LAYER_SET_NAME(SimpleCircle,"simple_circle");
54 SINFG_LAYER_SET_LOCAL_NAME(SimpleCircle,_("Simple Circle"));
55 SINFG_LAYER_SET_CATEGORY(SimpleCircle,_("Do Not Use"));
56 SINFG_LAYER_SET_VERSION(SimpleCircle,"0.1");
57 SINFG_LAYER_SET_CVS_ID(SimpleCircle,"$Id: simplecircle.cpp,v 1.1.1.1 2005/01/04 01:23:09 darco Exp $");
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 SimpleCircle::SimpleCircle():
66 Layer_Composite(1.0,Color::BLEND_STRAIGHT),
67 color(Color::black()),
74 SimpleCircle::set_param(const String & param, const ValueBase &value)
80 return Layer_Composite::set_param(param,value);
84 SimpleCircle::get_param(const String ¶m)const
93 return Layer_Composite::get_param(param);
97 SimpleCircle::get_param_vocab()const
99 Layer::Vocab ret(Layer_Composite::get_param_vocab());
101 ret.push_back(ParamDesc("color")
102 .set_local_name(_("Color"))
105 ret.push_back(ParamDesc("center")
106 .set_local_name(_("Center"))
109 ret.push_back(ParamDesc("radius")
110 .set_local_name(_("Radius"))
111 .set_description(_("This is the radius of the circle"))
112 .set_origin("center")
119 SimpleCircle::get_color(Context context, const Point &pos)const
122 if((pos-center).mag()<radius)
124 if(get_amount()==1.0 && get_blend_method()==Color::BLEND_STRAIGHT)
127 return Color::blend(color,context.get_color(pos),get_amount(),get_blend_method());
130 return context.get_color(pos);
134 SimpleCircle::hit_check(sinfg::Context context, const sinfg::Point &pos)const
136 if((pos-center).mag()<radius)
137 return const_cast<SimpleCircle*>(this);
139 return context.hit_check(pos);
144 SimpleCircle::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
146 if(get_amount()==1.0 && get_blend_method()==Color::BLEND_STRAIGHT)
148 // Mark our progress as starting
149 if(cb && !cb->amount_complete(0,1000))
152 surface->set_wh(renddesc.get_w(),renddesc.get_h());
153 surface->fill(color);
155 // Mark our progress as finished
156 if(cb && !cb->amount_complete(1000,1000))
162 SuperCallback supercb(cb,0,9500,10000);
164 if(!context.accelerated_render(surface,quality,renddesc,&supercb))
169 Surface::alpha_pen apen(surface->begin());
171 apen.set_value(color);
172 apen.set_alpha(get_amount());
173 apen.set_blend_method(get_blend_method());
175 for(y=0;y<renddesc.get_h();y++,apen.inc_y(),apen.dec_x(x))
176 for(x=0;x<renddesc.get_w();x++,apen.inc_x())
179 // Mark our progress as finished
180 if(cb && !cb->amount_complete(10000,10000))