1 /* === S Y N F I G ========================================================= */
2 /*! \file xorpattern.cpp
3 ** \brief Template Header
6 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
8 ** This package is free software; you can redistribute it and/or
9 ** modify it under the terms of the GNU General Public License as
10 ** published by the Free Software Foundation; either version 2 of
11 ** the License, or (at your option) any later version.
13 ** This package is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 ** General Public License for more details.
19 ** === N O T E S ===========================================================
21 ** ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include "xorpattern.h"
34 #include <synfig/string.h>
35 #include <synfig/time.h>
36 #include <synfig/context.h>
37 #include <synfig/paramdesc.h>
38 #include <synfig/renddesc.h>
39 #include <synfig/surface.h>
40 #include <synfig/value.h>
41 #include <synfig/valuenode.h>
45 /* === M A C R O S ========================================================= */
47 /* === G L O B A L S ======================================================= */
49 SYNFIG_LAYER_INIT(XORPattern);
50 SYNFIG_LAYER_SET_NAME(XORPattern,"XORPattern");
51 SYNFIG_LAYER_SET_LOCAL_NAME(XORPattern,_("XOR Pattern"));
52 SYNFIG_LAYER_SET_CATEGORY(XORPattern,_("Other"));
53 SYNFIG_LAYER_SET_VERSION(XORPattern,"0.1");
54 SYNFIG_LAYER_SET_CVS_ID(XORPattern,"$Id: xorpattern.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $");
56 /* === P R O C E D U R E S ================================================= */
58 /* === M E T H O D S ======================================================= */
60 XORPattern::XORPattern():
67 XORPattern::set_param(const String & param, const ValueBase &value)
75 XORPattern::get_param(const String & param)const
87 XORPattern::get_color(Context context, const Point &point)const
89 unsigned int a=(unsigned int)floor((point[0]+pos[0])/size[0]), b=(unsigned int)floor((point[1]+pos[1])/size[1]);
90 unsigned char rindex=(a^b);
91 unsigned char gindex=(a^(~b))*4;
92 unsigned char bindex=~(a^b)*2;
94 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);
98 XORPattern::get_param_vocab()const
102 ret.push_back(ParamDesc("pos")
103 .set_local_name(_("Offset"))
105 ret.push_back(ParamDesc("size")
106 .set_local_name(_("Size"))