1 /* === S Y N F I G ========================================================= */
5 ** $Id: zoom.cpp,v 1.2 2005/01/24 03:08:17 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 ======================================================= */
32 #include <synfig/string.h>
33 #include <synfig/time.h>
34 #include <synfig/context.h>
35 #include <synfig/paramdesc.h>
36 #include <synfig/renddesc.h>
37 #include <synfig/surface.h>
38 #include <synfig/value.h>
39 #include <synfig/valuenode.h>
40 #include <synfig/transform.h>
44 /* === M A C R O S ========================================================= */
46 /* === G L O B A L S ======================================================= */
48 SYNFIG_LAYER_INIT(Zoom);
49 SYNFIG_LAYER_SET_NAME(Zoom,"zoom");
50 SYNFIG_LAYER_SET_LOCAL_NAME(Zoom,_("Zoom"));
51 SYNFIG_LAYER_SET_CATEGORY(Zoom,_("Transform"));
52 SYNFIG_LAYER_SET_VERSION(Zoom,"0.1");
53 SYNFIG_LAYER_SET_CVS_ID(Zoom,"$Id: zoom.cpp,v 1.2 2005/01/24 03:08:17 darco Exp $");
55 /* === P R O C E D U R E S ================================================= */
57 /* === M E T H O D S ======================================================= */
59 /* === E N T R Y P O I N T ================================================= */
68 Zoom::set_param(const String & param, const ValueBase &value)
78 Zoom::get_param(const String ¶m)const
90 Zoom::get_param_vocab()const
94 ret.push_back(ParamDesc("amount")
95 .set_local_name(_("Amount"))
96 .set_description(_("Amount to zoom in"))
99 ret.push_back(ParamDesc("center")
100 .set_local_name(_("Center"))
101 .set_description(_("Point to zoom in to"))
107 synfig::Layer::Handle
108 Zoom::hit_check(synfig::Context context, const synfig::Point &pos)const
110 return context.hit_check((pos-center)/exp(amount)+center);
114 Zoom::get_color(Context context, const Point &pos)const
116 return context.get_color((pos-center)/exp(amount)+center);
119 class Zoom_Trans : public Transform
121 etl::handle<const Zoom> layer;
123 Zoom_Trans(const Zoom* x):Transform(x->get_guid()),layer(x) { }
125 synfig::Vector perform(const synfig::Vector& x)const
127 return (x-layer->center)*exp(layer->amount)+layer->center;
130 synfig::Vector unperform(const synfig::Vector& x)const
132 return (x-layer->center)/exp(layer->amount)+layer->center;
135 etl::handle<Transform>
136 Zoom::get_transform()const
138 return new Zoom_Trans(this);
142 Zoom::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
144 Vector::value_type zoomfactor=1.0/exp(amount);
145 RendDesc desc(renddesc);
148 // Adjust the top_left and bottom_right points
149 // for our zoom amount
150 desc.set_tl((desc.get_tl()-center)*zoomfactor+center);
151 desc.set_br((desc.get_br()-center)*zoomfactor+center);
154 return context.accelerated_render(surface,quality,desc,cb);
158 Zoom::get_full_bounding_rect(synfig::Context context)const
160 return context.get_full_bounding_rect();