1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.4
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 #ifndef AGG_GAMMA_FUNCTIONS_INCLUDED
17 #define AGG_GAMMA_FUNCTIONS_INCLUDED
20 #include "agg_basics.h"
24 //===============================================================gamma_none
27 double operator()(double x
) const { return x
; }
31 //==============================================================gamma_power
35 gamma_power() : m_gamma(1.0) {}
36 gamma_power(double g
) : m_gamma(g
) {}
38 void gamma(double g
) { m_gamma
= g
; }
39 double gamma() const { return m_gamma
; }
41 double operator() (double x
) const
43 return pow(x
, m_gamma
);
51 //==========================================================gamma_threshold
55 gamma_threshold() : m_threshold(0.5) {}
56 gamma_threshold(double t
) : m_threshold(t
) {}
58 void threshold(double t
) { m_threshold
= t
; }
59 double threshold() const { return m_threshold
; }
61 double operator() (double x
) const
63 return (x
< m_threshold
) ? 0.0 : 1.0;
71 //============================================================gamma_linear
75 gamma_linear() : m_start(0.0), m_end(1.0) {}
76 gamma_linear(double s
, double e
) : m_start(s
), m_end(e
) {}
78 void set(double s
, double e
) { m_start
= s
; m_end
= e
; }
79 void start(double s
) { m_start
= s
; }
80 void end(double e
) { m_end
= e
; }
81 double start() const { return m_start
; }
82 double end() const { return m_end
; }
84 double operator() (double x
) const
86 if(x
< m_start
) return 0.0;
87 if(x
> m_end
) return 1.0;
88 return (x
- m_start
) / (m_end
- m_start
);
97 //==========================================================gamma_multiply
101 gamma_multiply() : m_mul(1.0) {}
102 gamma_multiply(double v
) : m_mul(v
) {}
104 void value(double v
) { m_mul
= v
; }
105 double value() const { return m_mul
; }
107 double operator() (double x
) const
109 double y
= x
* m_mul
;