1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.3
3 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
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.
10 //----------------------------------------------------------------------------
11 // Contact: mcseem@antigrain.com
12 // mcseemagg@yahoo.com
13 // http://www.antigrain.com
14 //----------------------------------------------------------------------------
16 // Horizontal span interpolator for use with an arbitrary transformer
17 // The efficiency highly depends on the operations done in the transformer
19 //----------------------------------------------------------------------------
21 #ifndef AGG_SPAN_INTERPOLATOR_TRANS_INCLUDED
22 #define AGG_SPAN_INTERPOLATOR_TRANS_INCLUDED
24 #include "agg_basics.h"
28 //=================================================span_interpolator_trans
29 template<class Transformer
, unsigned SubpixelShift
= 8>
30 class span_interpolator_trans
33 typedef Transformer trans_type
;
36 subpixel_shift
= SubpixelShift
,
37 subpixel_size
= 1 << subpixel_shift
40 //--------------------------------------------------------------------
41 span_interpolator_trans() {}
42 span_interpolator_trans(const trans_type
& trans
) : m_trans(&trans
) {}
43 span_interpolator_trans(const trans_type
& trans
,
44 double x
, double y
, unsigned) :
50 //----------------------------------------------------------------
51 const trans_type
& transformer() const { return *m_trans
; }
52 void transformer(const trans_type
& trans
) { m_trans
= &trans
; }
54 //----------------------------------------------------------------
55 void begin(double x
, double y
, unsigned)
59 m_trans
->transform(&x
, &y
);
60 m_ix
= int(x
* subpixel_size
);
61 m_iy
= int(y
* subpixel_size
);
64 //----------------------------------------------------------------
65 void next(double, double, unsigned)
69 //----------------------------------------------------------------
75 m_trans
->transform(&x
, &y
);
76 m_ix
= int(x
* subpixel_size
);
77 m_iy
= int(y
* subpixel_size
);
80 //----------------------------------------------------------------
81 void coordinates(int* x
, int* y
) const
88 const trans_type
* m_trans
;