1 /* === S Y N F I G ========================================================= */
3 ** \brief Template Header
5 ** $Id: stretch.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === H E A D E R S ======================================================= */
24 #define SYNFIG_NO_ANGLE
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 /* === U S I N G =========================================================== */
50 using namespace synfig;
52 /* === G L O B A L S ======================================================= */
54 SYNFIG_LAYER_INIT(Layer_Stretch);
55 SYNFIG_LAYER_SET_NAME(Layer_Stretch,"stretch");
56 SYNFIG_LAYER_SET_LOCAL_NAME(Layer_Stretch,_("Stretch"));
57 SYNFIG_LAYER_SET_CATEGORY(Layer_Stretch,_("Distortions"));
58 SYNFIG_LAYER_SET_VERSION(Layer_Stretch,"0.1");
59 SYNFIG_LAYER_SET_CVS_ID(Layer_Stretch,"$Id: stretch.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $");
61 /* === P R O C E D U R E S ================================================= */
63 /* === M E T H O D S ======================================================= */
65 /* === E N T R Y P O I N T ================================================= */
67 Layer_Stretch::Layer_Stretch():
75 Layer_Stretch::set_param(const String & param, const ValueBase &value)
84 Layer_Stretch::get_param(const String ¶m)const
96 Layer_Stretch::get_param_vocab()const
100 ret.push_back(ParamDesc("amount")
101 .set_local_name(_("Amount"))
104 ret.push_back(ParamDesc("center")
105 .set_local_name(_("Center"))
111 synfig::Layer::Handle
112 Layer_Stretch::hit_check(synfig::Context context, const synfig::Point &pos)const
115 npos[0]=(npos[0]-center[0])/amount[0]+center[0];
116 npos[1]=(npos[1]-center[1])/amount[1]+center[1];
117 return context.hit_check(npos);
121 Layer_Stretch::get_color(Context context, const Point &pos)const
124 npos[0]=(npos[0]-center[0])/amount[0]+center[0];
125 npos[1]=(npos[1]-center[1])/amount[1]+center[1];
126 return context.get_color(npos);
129 class Stretch_Trans : public Transform
131 etl::handle<const Layer_Stretch> layer;
133 Stretch_Trans(const Layer_Stretch* x):Transform(x->get_guid()),layer(x) { }
135 synfig::Vector perform(const synfig::Vector& x)const
137 return Vector((x[0]-layer->center[0])*layer->amount[0]+layer->center[0],(x[1]-layer->center[1])*layer->amount[1]+layer->center[1]);
140 synfig::Vector unperform(const synfig::Vector& x)const
142 return Vector((x[0]-layer->center[0])/layer->amount[0]+layer->center[0],(x[1]-layer->center[1])/layer->amount[1]+layer->center[1]);
145 etl::handle<Transform>
146 Layer_Stretch::get_transform()const
148 return new Stretch_Trans(this);
152 Layer_Stretch::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
154 RendDesc desc(renddesc);
156 // Adjust the top_left and bottom_right points
157 // for our zoom amount
159 npos[0]=(desc.get_tl()[0]-center[0])/amount[0]+center[0];
160 npos[1]=(desc.get_tl()[1]-center[1])/amount[1]+center[1];
162 npos[0]=(desc.get_br()[0]-center[0])/amount[0]+center[0];
163 npos[1]=(desc.get_br()[1]-center[1])/amount[1]+center[1];
167 return context.accelerated_render(surface,quality,desc,cb);