merge the formfield patch from ooo-build
[ooovba.git] / agg / source / agg_trans_warp_magnifier.cpp
blob5bde578a5611d61b1c214b7bb85d5b6db7dade92
1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.3
3 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
4 //
5 // Permission to copy, use, modify, sell and distribute this software
6 // is granted provided this copyright notice appears in all copies.
7 // This software is provided "as is" without express or implied
8 // warranty, and with no claim as to its suitability for any purpose.
9 //
10 //----------------------------------------------------------------------------
11 // Contact: mcseem@antigrain.com
12 // mcseemagg@yahoo.com
13 // http://www.antigrain.com
14 //----------------------------------------------------------------------------
16 #include <math.h>
17 #include "agg_trans_warp_magnifier.h"
19 namespace agg
22 //------------------------------------------------------------------------
23 void trans_warp_magnifier::transform(double* x, double* y) const
25 double dx = *x - m_xc;
26 double dy = *y - m_yc;
27 double r = sqrt(dx * dx + dy * dy);
28 if(r < m_radius)
30 *x = m_xc + dx * m_magn;
31 *y = m_yc + dy * m_magn;
32 return;
35 double m = (r + m_radius * (m_magn - 1.0)) / r;
36 *x = m_xc + dx * m;
37 *y = m_yc + dy * m;
40 //------------------------------------------------------------------------
41 void trans_warp_magnifier::inverse_transform(double* x, double* y) const
43 trans_warp_magnifier t(*this);
44 t.magnification(1.0 / m_magn);
45 t.radius(m_radius * m_magn);
46 t.transform(x, y);