1 /* === S Y N F I G ========================================================= */
2 /*! \file xorpattern.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 ** === N O T E S ===========================================================
23 ** ========================================================================= */
25 /* === H E A D E R S ======================================================= */
34 #include "xorpattern.h"
36 #include <synfig/string.h>
37 #include <synfig/time.h>
38 #include <synfig/context.h>
39 #include <synfig/paramdesc.h>
40 #include <synfig/renddesc.h>
41 #include <synfig/surface.h>
42 #include <synfig/value.h>
43 #include <synfig/valuenode.h>
47 /* === M A C R O S ========================================================= */
49 /* === G L O B A L S ======================================================= */
51 SYNFIG_LAYER_INIT(XORPattern);
52 SYNFIG_LAYER_SET_NAME(XORPattern,"XORPattern");
53 SYNFIG_LAYER_SET_LOCAL_NAME(XORPattern,_("XOR Pattern"));
54 SYNFIG_LAYER_SET_CATEGORY(XORPattern,_("Other"));
55 SYNFIG_LAYER_SET_VERSION(XORPattern,"0.1");
56 SYNFIG_LAYER_SET_CVS_ID(XORPattern,"$Id$");
58 /* === P R O C E D U R E S ================================================= */
60 /* === M E T H O D S ======================================================= */
62 XORPattern::XORPattern():
69 XORPattern::set_param(const String & param, const ValueBase &value)
77 XORPattern::get_param(const String & param)const
89 XORPattern::get_color(Context context, const Point &point)const
91 unsigned int a=(unsigned int)floor((point[0]+pos[0])/size[0]), b=(unsigned int)floor((point[1]+pos[1])/size[1]);
92 unsigned char rindex=(a^b);
93 unsigned char gindex=(a^(~b))*4;
94 unsigned char bindex=~(a^b)*2;
96 return Color((Color::value_type)rindex/(Color::value_type)255.0,(Color::value_type)gindex/(Color::value_type)255.0,(Color::value_type)bindex/(Color::value_type)255.0,1.0);
100 XORPattern::get_param_vocab()const
104 ret.push_back(ParamDesc("pos")
105 .set_local_name(_("Offset"))
107 ret.push_back(ParamDesc("size")
108 .set_local_name(_("Size"))