1 /* === S I N F G =========================================================== */
2 /*! \file checkerboard.cpp
3 ** \brief Template Header
5 ** $Id: lumakey.cpp,v 1.1.1.1 2005/01/04 01:23:10 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 ======================================================= */
33 #include <sinfg/string.h>
34 #include <sinfg/time.h>
35 #include <sinfg/context.h>
36 #include <sinfg/paramdesc.h>
37 #include <sinfg/renddesc.h>
38 #include <sinfg/surface.h>
39 #include <sinfg/value.h>
40 #include <sinfg/valuenode.h>
41 #include <sinfg/segment.h>
45 using namespace sinfg;
49 /* === M A C R O S ========================================================= */
51 /* === G L O B A L S ======================================================= */
53 SINFG_LAYER_INIT(LumaKey);
54 SINFG_LAYER_SET_NAME(LumaKey,"lumakey");
55 SINFG_LAYER_SET_LOCAL_NAME(LumaKey,_("LumaKey"));
56 SINFG_LAYER_SET_CATEGORY(LumaKey,_("Filters"));
57 SINFG_LAYER_SET_VERSION(LumaKey,"0.1");
58 SINFG_LAYER_SET_CVS_ID(LumaKey,"$Id: lumakey.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $");
60 /* === P R O C E D U R E S ================================================= */
62 /* === M E T H O D S ======================================================= */
65 Layer_Composite (1.0,Color::BLEND_STRAIGHT)
67 set_blend_method(Color::BLEND_STRAIGHT);
72 LumaKey::set_param(const String ¶m, const ValueBase &value)
74 return Layer_Composite::set_param(param,value);
78 LumaKey::get_param(const String ¶m)const
83 return Layer_Composite::get_param(param);
87 LumaKey::get_param_vocab()const
89 Layer::Vocab ret(Layer_Composite::get_param_vocab());
91 /* ret.push_back(ParamDesc("color")
92 .set_local_name(_("Color"))
93 .set_description(_("Color of checkers"))
95 ret.push_back(ParamDesc("pos")
96 .set_local_name(_("Offset"))
98 ret.push_back(ParamDesc("size")
99 .set_local_name(_("Size"))
100 .set_description(_("Size of checkers"))
108 LumaKey::hit_check(sinfg::Context context, const sinfg::Point &getpos)const
110 return context.hit_check(getpos);
114 LumaKey::get_color(Context context, const Point &getpos)const
116 const Color color(context.get_color(getpos));
118 if(get_amount()==0.0)
122 ret.set_a(ret.get_y()*ret.get_a());
125 if(get_amount()==1.0 && get_blend_method()==Color::BLEND_STRAIGHT)
128 return Color::blend(ret,color,get_amount(),get_blend_method());
132 LumaKey::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
134 SuperCallback supercb(cb,0,9500,10000);
136 if(!context.accelerated_render(surface,quality,renddesc,&supercb))
141 Surface::pen pen(surface->begin());
143 for(y=0;y<renddesc.get_h();y++,pen.inc_y(),pen.dec_x(x))
144 for(x=0;x<renddesc.get_w();x++,pen.inc_x())
146 Color tmp(pen.get_value());
147 tmp.set_a(tmp.get_y()*tmp.get_a());
152 // Mark our progress as finished
153 if(cb && !cb->amount_complete(10000,10000))
160 LumaKey::get_bounding_rect(Context context)const
165 return context.get_full_bounding_rect();