1 /* === S Y N F I G ========================================================= */
2 /*! \file insideout.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 "insideout.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>
44 #include <synfig/transform.h>
48 /* === M A C R O S ========================================================= */
50 /* === G L O B A L S ======================================================= */
52 SYNFIG_LAYER_INIT(InsideOut);
53 SYNFIG_LAYER_SET_NAME(InsideOut,"inside_out");
54 SYNFIG_LAYER_SET_LOCAL_NAME(InsideOut,_("Inside Out"));
55 SYNFIG_LAYER_SET_CATEGORY(InsideOut,_("Distortions"));
56 SYNFIG_LAYER_SET_VERSION(InsideOut,"0.1");
57 SYNFIG_LAYER_SET_CVS_ID(InsideOut,"$Id$");
59 /* === P R O C E D U R E S ================================================= */
61 /* === M E T H O D S ======================================================= */
63 InsideOut::InsideOut():
69 InsideOut::set_param(const String & param, const ValueBase &value)
76 InsideOut::get_param(const String & param)const
87 InsideOut::hit_check(synfig::Context context, const synfig::Point &p)const
90 Real inv_mag=pos.inv_mag();
91 Point invpos(pos*inv_mag*inv_mag);
92 return context.hit_check(invpos+origin);
96 InsideOut::get_color(Context context, const Point &p)const
99 Real inv_mag=pos.inv_mag();
100 Point invpos(pos*inv_mag*inv_mag);
101 return context.get_color(invpos+origin);
104 class InsideOut_Trans : public Transform
106 etl::handle<const InsideOut> layer;
108 InsideOut_Trans(const InsideOut* x):layer(x) { }
110 synfig::Vector perform(const synfig::Vector& x)const
112 Point pos(x-layer->origin);
113 Real inv_mag=pos.inv_mag();
115 return (pos*(inv_mag*inv_mag)+layer->origin);
119 synfig::Vector unperform(const synfig::Vector& x)const
121 Point pos(x-layer->origin);
122 Real inv_mag=pos.inv_mag();
124 return (pos*(inv_mag*inv_mag)+layer->origin);
128 etl::handle<Transform>
129 InsideOut::get_transform()const
131 return new InsideOut_Trans(this);
135 InsideOut::get_param_vocab()const
139 ret.push_back(ParamDesc("origin")
140 .set_local_name(_("Origin"))
141 .set_description(_("Defines the where the center will be"))