1 /*! ========================================================================
4 ** $Id: insideout.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $
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.
18 ** === N O T E S ===========================================================
20 ** ========================================================================= */
22 /* === H E A D E R S ======================================================= */
31 #include "insideout.h"
33 #include <synfig/string.h>
34 #include <synfig/time.h>
35 #include <synfig/context.h>
36 #include <synfig/paramdesc.h>
37 #include <synfig/renddesc.h>
38 #include <synfig/surface.h>
39 #include <synfig/value.h>
40 #include <synfig/valuenode.h>
41 #include <synfig/transform.h>
45 /* === M A C R O S ========================================================= */
47 /* === G L O B A L S ======================================================= */
49 SYNFIG_LAYER_INIT(InsideOut);
50 SYNFIG_LAYER_SET_NAME(InsideOut,"inside_out");
51 SYNFIG_LAYER_SET_LOCAL_NAME(InsideOut,_("InsideOut"));
52 SYNFIG_LAYER_SET_CATEGORY(InsideOut,_("Distortions"));
53 SYNFIG_LAYER_SET_VERSION(InsideOut,"0.1");
54 SYNFIG_LAYER_SET_CVS_ID(InsideOut,"$Id: insideout.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 InsideOut::InsideOut():
66 InsideOut::set_param(const String & param, const ValueBase &value)
73 InsideOut::get_param(const String & param)const
84 InsideOut::hit_check(synfig::Context context, const synfig::Point &p)const
87 Real inv_mag=pos.inv_mag();
88 Point invpos(pos*inv_mag*inv_mag);
89 return context.hit_check(invpos+origin);
93 InsideOut::get_color(Context context, const Point &p)const
96 Real inv_mag=pos.inv_mag();
97 Point invpos(pos*inv_mag*inv_mag);
98 return context.get_color(invpos+origin);
101 class InsideOut_Trans : public Transform
103 etl::handle<const InsideOut> layer;
105 InsideOut_Trans(const InsideOut* x):layer(x) { }
107 synfig::Vector perform(const synfig::Vector& x)const
109 Point pos(x-layer->origin);
110 Real inv_mag=pos.inv_mag();
112 return (pos*(inv_mag*inv_mag)+layer->origin);
116 synfig::Vector unperform(const synfig::Vector& x)const
118 Point pos(x-layer->origin);
119 Real inv_mag=pos.inv_mag();
121 return (pos*(inv_mag*inv_mag)+layer->origin);
125 etl::handle<Transform>
126 InsideOut::get_transform()const
128 return new InsideOut_Trans(this);
132 InsideOut::get_param_vocab()const
136 ret.push_back(ParamDesc("origin")
137 .set_local_name(_("Origin"))
138 .set_description(_("Defines the where the center will be"))