1 /*! ========================================================================
4 ** $Id: xorpattern.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $
6 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
8 ** This software and associated documentation
9 ** are CONFIDENTIAL and PROPRIETARY property of
10 ** the above-mentioned copyright holder.
12 ** You may not copy, print, publish, or in any
13 ** other way distribute this software without
14 ** a prior written agreement with
15 ** the copyright holder.
17 ** === N O T E S ===========================================================
19 ** ========================================================================= */
21 /* === H E A D E R S ======================================================= */
30 #include "xorpattern.h"
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>
43 /* === M A C R O S ========================================================= */
45 /* === G L O B A L S ======================================================= */
47 SYNFIG_LAYER_INIT(XORPattern);
48 SYNFIG_LAYER_SET_NAME(XORPattern,"XORPattern");
49 SYNFIG_LAYER_SET_LOCAL_NAME(XORPattern,_("XOR Pattern"));
50 SYNFIG_LAYER_SET_CATEGORY(XORPattern,_("Other"));
51 SYNFIG_LAYER_SET_VERSION(XORPattern,"0.1");
52 SYNFIG_LAYER_SET_CVS_ID(XORPattern,"$Id: xorpattern.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $");
54 /* === P R O C E D U R E S ================================================= */
56 /* === M E T H O D S ======================================================= */
58 XORPattern::XORPattern():
65 XORPattern::set_param(const String & param, const ValueBase &value)
73 XORPattern::get_param(const String & param)const
85 XORPattern::get_color(Context context, const Point &point)const
87 unsigned int a=(unsigned int)floor((point[0]+pos[0])/size[0]), b=(unsigned int)floor((point[1]+pos[1])/size[1]);
88 unsigned char rindex=(a^b);
89 unsigned char gindex=(a^(~b))*4;
90 unsigned char bindex=~(a^b)*2;
92 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);
96 XORPattern::get_param_vocab()const
100 ret.push_back(ParamDesc("pos")
101 .set_local_name(_("Offset"))
103 ret.push_back(ParamDesc("size")
104 .set_local_name(_("Size"))