xref: /haiku/headers/libs/agg/agg_span_interpolator_adaptor.h (revision e39da397f5ff79f2db9f9a3ddf1852b6710578af)
139241fe2SDarkWyrm //----------------------------------------------------------------------------
2*e39da397SStephan Aßmus // Anti-Grain Geometry - Version 2.4
3*e39da397SStephan Aßmus // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
439241fe2SDarkWyrm //
539241fe2SDarkWyrm // Permission to copy, use, modify, sell and distribute this software
639241fe2SDarkWyrm // is granted provided this copyright notice appears in all copies.
739241fe2SDarkWyrm // This software is provided "as is" without express or implied
839241fe2SDarkWyrm // warranty, and with no claim as to its suitability for any purpose.
939241fe2SDarkWyrm //
1039241fe2SDarkWyrm //----------------------------------------------------------------------------
1139241fe2SDarkWyrm // Contact: mcseem@antigrain.com
1239241fe2SDarkWyrm //          mcseemagg@yahoo.com
1339241fe2SDarkWyrm //          http://www.antigrain.com
1439241fe2SDarkWyrm //----------------------------------------------------------------------------
1539241fe2SDarkWyrm 
1639241fe2SDarkWyrm #ifndef AGG_SPAN_INTERPOLATOR_ADAPTOR_INCLUDED
1739241fe2SDarkWyrm #define AGG_SPAN_INTERPOLATOR_ADAPTOR_INCLUDED
1839241fe2SDarkWyrm 
1939241fe2SDarkWyrm #include "agg_basics.h"
2039241fe2SDarkWyrm 
2139241fe2SDarkWyrm namespace agg
2239241fe2SDarkWyrm {
2339241fe2SDarkWyrm 
2439241fe2SDarkWyrm     //===============================================span_interpolator_adaptor
2539241fe2SDarkWyrm     template<class Interpolator, class Distortion>
2639241fe2SDarkWyrm     class span_interpolator_adaptor : public Interpolator
2739241fe2SDarkWyrm     {
2839241fe2SDarkWyrm     public:
2939241fe2SDarkWyrm         typedef Interpolator base_type;
3039241fe2SDarkWyrm         typedef typename base_type::trans_type trans_type;
3139241fe2SDarkWyrm         typedef Distortion distortion_type;
3239241fe2SDarkWyrm 
3339241fe2SDarkWyrm         //--------------------------------------------------------------------
span_interpolator_adaptor()3439241fe2SDarkWyrm         span_interpolator_adaptor() {}
span_interpolator_adaptor(const trans_type & trans,const distortion_type & dist)3539241fe2SDarkWyrm         span_interpolator_adaptor(const trans_type& trans,
3639241fe2SDarkWyrm                                   const distortion_type& dist) :
3739241fe2SDarkWyrm             base_type(trans),
3839241fe2SDarkWyrm             m_distortion(&dist)
3939241fe2SDarkWyrm         {
4039241fe2SDarkWyrm         }
4139241fe2SDarkWyrm 
4239241fe2SDarkWyrm         //--------------------------------------------------------------------
span_interpolator_adaptor(const trans_type & trans,const distortion_type & dist,double x,double y,unsigned len)4339241fe2SDarkWyrm         span_interpolator_adaptor(const trans_type& trans,
4439241fe2SDarkWyrm                                   const distortion_type& dist,
4539241fe2SDarkWyrm                                   double x, double y, unsigned len) :
4639241fe2SDarkWyrm             base_type(trans, x, y, len),
4739241fe2SDarkWyrm             m_distortion(&dist)
4839241fe2SDarkWyrm         {
4939241fe2SDarkWyrm         }
5039241fe2SDarkWyrm 
5139241fe2SDarkWyrm         //--------------------------------------------------------------------
distortion()5239241fe2SDarkWyrm         const distortion_type& distortion() const
5339241fe2SDarkWyrm         {
5439241fe2SDarkWyrm             return *m_distortion;
5539241fe2SDarkWyrm         }
5639241fe2SDarkWyrm 
5739241fe2SDarkWyrm         //--------------------------------------------------------------------
distortion(const distortion_type & dist)5839241fe2SDarkWyrm         void distortion(const distortion_type& dist)
5939241fe2SDarkWyrm         {
6039241fe2SDarkWyrm             m_distortion = dist;
6139241fe2SDarkWyrm         }
6239241fe2SDarkWyrm 
6339241fe2SDarkWyrm         //--------------------------------------------------------------------
coordinates(int * x,int * y)6439241fe2SDarkWyrm         void coordinates(int* x, int* y) const
6539241fe2SDarkWyrm         {
6639241fe2SDarkWyrm             base_type::coordinates(x, y);
6739241fe2SDarkWyrm             m_distortion->calculate(x, y);
6839241fe2SDarkWyrm         }
6939241fe2SDarkWyrm 
7039241fe2SDarkWyrm     private:
7139241fe2SDarkWyrm         //--------------------------------------------------------------------
7239241fe2SDarkWyrm         const distortion_type* m_distortion;
7339241fe2SDarkWyrm     };
7439241fe2SDarkWyrm }
7539241fe2SDarkWyrm 
7639241fe2SDarkWyrm 
7739241fe2SDarkWyrm #endif
78