1//----------------------------------------------------------------------------
2// Anti-Grain Geometry - Version 2.4
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//----------------------------------------------------------------------------
15
16#ifndef AGG_SPAN_INTERPOLATOR_ADAPTOR_INCLUDED
17#define AGG_SPAN_INTERPOLATOR_ADAPTOR_INCLUDED
18
19#include "agg_basics.h"
20
21namespace agg
22{
23
24    //===============================================span_interpolator_adaptor
25    template<class Interpolator, class Distortion>
26    class span_interpolator_adaptor : public Interpolator
27    {
28    public:
29        typedef Interpolator base_type;
30        typedef typename base_type::trans_type trans_type;
31        typedef Distortion distortion_type;
32
33        //--------------------------------------------------------------------
34        span_interpolator_adaptor() {}
35        span_interpolator_adaptor(const trans_type& trans,
36                                  const distortion_type& dist) :
37            base_type(trans),
38            m_distortion(&dist)
39        {
40        }
41
42        //--------------------------------------------------------------------
43        span_interpolator_adaptor(const trans_type& trans,
44                                  const distortion_type& dist,
45                                  double x, double y, unsigned len) :
46            base_type(trans, x, y, len),
47            m_distortion(&dist)
48        {
49        }
50
51        //--------------------------------------------------------------------
52        const distortion_type& distortion() const
53        {
54            return *m_distortion;
55        }
56
57        //--------------------------------------------------------------------
58        void distortion(const distortion_type& dist)
59        {
60            m_distortion = dist;
61        }
62
63        //--------------------------------------------------------------------
64        void coordinates(int* x, int* y) const
65        {
66            base_type::coordinates(x, y);
67            m_distortion->calculate(x, y);
68        }
69
70    private:
71        //--------------------------------------------------------------------
72        const distortion_type* m_distortion;
73    };
74}
75
76
77#endif
78