1 /* === S Y N F I G ========================================================= */
2 /*! \file insideout.cpp
3 ** \brief Implementation of the "Inside Out" layer
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2007 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 ** === N O T E S ===========================================================
24 ** ========================================================================= */
26 /* === H E A D E R S ======================================================= */
35 #include "insideout.h"
37 #include <synfig/string.h>
38 #include <synfig/time.h>
39 #include <synfig/context.h>
40 #include <synfig/paramdesc.h>
41 #include <synfig/renddesc.h>
42 #include <synfig/surface.h>
43 #include <synfig/value.h>
44 #include <synfig/valuenode.h>
45 #include <synfig/transform.h>
49 /* === M A C R O S ========================================================= */
51 /* === G L O B A L S ======================================================= */
53 SYNFIG_LAYER_INIT(InsideOut
);
54 SYNFIG_LAYER_SET_NAME(InsideOut
,"inside_out");
55 SYNFIG_LAYER_SET_LOCAL_NAME(InsideOut
,N_("Inside Out"));
56 SYNFIG_LAYER_SET_CATEGORY(InsideOut
,N_("Distortions"));
57 SYNFIG_LAYER_SET_VERSION(InsideOut
,"0.1");
58 SYNFIG_LAYER_SET_CVS_ID(InsideOut
,"$Id$");
60 /* === P R O C E D U R E S ================================================= */
62 /* === M E T H O D S ======================================================= */
64 InsideOut::InsideOut():
70 InsideOut::set_param(const String
& param
, const ValueBase
&value
)
77 InsideOut::get_param(const String
& param
)const
88 InsideOut::hit_check(synfig::Context context
, const synfig::Point
&p
)const
91 Real inv_mag
=pos
.inv_mag();
92 Point
invpos(pos
*inv_mag
*inv_mag
);
93 return context
.hit_check(invpos
+origin
);
97 InsideOut::get_color(Context context
, const Point
&p
)const
100 Real inv_mag
=pos
.inv_mag();
101 Point
invpos(pos
*inv_mag
*inv_mag
);
102 return context
.get_color(invpos
+origin
);
105 class InsideOut_Trans
: public Transform
107 etl::handle
<const InsideOut
> layer
;
109 InsideOut_Trans(const InsideOut
* x
):Transform(x
->get_guid()),layer(x
) { }
111 synfig::Vector
perform(const synfig::Vector
& x
)const
113 Point
pos(x
-layer
->origin
);
114 Real inv_mag
=pos
.inv_mag();
116 return (pos
*(inv_mag
*inv_mag
)+layer
->origin
);
120 synfig::Vector
unperform(const synfig::Vector
& x
)const
122 Point
pos(x
-layer
->origin
);
123 Real inv_mag
=pos
.inv_mag();
125 return (pos
*(inv_mag
*inv_mag
)+layer
->origin
);
129 etl::handle
<Transform
>
130 InsideOut::get_transform()const
132 return new InsideOut_Trans(this);
136 InsideOut::get_param_vocab()const
140 ret
.push_back(ParamDesc("origin")
141 .set_local_name(_("Origin"))
142 .set_description(_("Defines the where the center will be"))