1 /* === S Y N F I G ========================================================= */
2 /*! \file insideout.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 "insideout.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>
42 #include <synfig/transform.h>
46 /* === M A C R O S ========================================================= */
48 /* === G L O B A L S ======================================================= */
50 SYNFIG_LAYER_INIT(InsideOut);
51 SYNFIG_LAYER_SET_NAME(InsideOut,"inside_out");
52 SYNFIG_LAYER_SET_LOCAL_NAME(InsideOut,_("InsideOut"));
53 SYNFIG_LAYER_SET_CATEGORY(InsideOut,_("Distortions"));
54 SYNFIG_LAYER_SET_VERSION(InsideOut,"0.1");
55 SYNFIG_LAYER_SET_CVS_ID(InsideOut,"$Id: insideout.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $");
57 /* === P R O C E D U R E S ================================================= */
59 /* === M E T H O D S ======================================================= */
61 InsideOut::InsideOut():
67 InsideOut::set_param(const String & param, const ValueBase &value)
74 InsideOut::get_param(const String & param)const
85 InsideOut::hit_check(synfig::Context context, const synfig::Point &p)const
88 Real inv_mag=pos.inv_mag();
89 Point invpos(pos*inv_mag*inv_mag);
90 return context.hit_check(invpos+origin);
94 InsideOut::get_color(Context context, const Point &p)const
97 Real inv_mag=pos.inv_mag();
98 Point invpos(pos*inv_mag*inv_mag);
99 return context.get_color(invpos+origin);
102 class InsideOut_Trans : public Transform
104 etl::handle<const InsideOut> layer;
106 InsideOut_Trans(const InsideOut* x):layer(x) { }
108 synfig::Vector perform(const synfig::Vector& x)const
110 Point pos(x-layer->origin);
111 Real inv_mag=pos.inv_mag();
113 return (pos*(inv_mag*inv_mag)+layer->origin);
117 synfig::Vector unperform(const synfig::Vector& x)const
119 Point pos(x-layer->origin);
120 Real inv_mag=pos.inv_mag();
122 return (pos*(inv_mag*inv_mag)+layer->origin);
126 etl::handle<Transform>
127 InsideOut::get_transform()const
129 return new InsideOut_Trans(this);
133 InsideOut::get_param_vocab()const
137 ret.push_back(ParamDesc("origin")
138 .set_local_name(_("Origin"))
139 .set_description(_("Defines the where the center will be"))