00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef AGG_GAMMA_FUNCTIONS_INCLUDED
00017 #define AGG_GAMMA_FUNCTIONS_INCLUDED
00018
00019 #include <math.h>
00020 #include "agg_basics.h"
00021
00022 namespace agg
00023 {
00024
00025 struct gamma_none
00026 {
00027 double operator()(double x) const { return x; }
00028 };
00029
00030
00031
00032 class gamma_power
00033 {
00034 public:
00035 gamma_power() : m_gamma(1.0) {}
00036 gamma_power(double g) : m_gamma(g) {}
00037
00038 void gamma(double g) { m_gamma = g; }
00039 double gamma() const { return m_gamma; }
00040
00041 double operator() (double x) const
00042 {
00043 return pow(x, m_gamma);
00044 }
00045
00046 private:
00047 double m_gamma;
00048 };
00049
00050
00051
00052 class gamma_threshold
00053 {
00054 public:
00055 gamma_threshold() : m_threshold(0.5) {}
00056 gamma_threshold(double t) : m_threshold(t) {}
00057
00058 void threshold(double t) { m_threshold = t; }
00059 double threshold() const { return m_threshold; }
00060
00061 double operator() (double x) const
00062 {
00063 return (x < m_threshold) ? 0.0 : 1.0;
00064 }
00065
00066 private:
00067 double m_threshold;
00068 };
00069
00070
00071
00072 class gamma_linear
00073 {
00074 public:
00075 gamma_linear() : m_start(0.0), m_end(1.0) {}
00076 gamma_linear(double s, double e) : m_start(s), m_end(e) {}
00077
00078 void set(double s, double e) { m_start = s; m_end = e; }
00079 void start(double s) { m_start = s; }
00080 void end(double e) { m_end = e; }
00081 double start() const { return m_start; }
00082 double end() const { return m_end; }
00083
00084 double operator() (double x) const
00085 {
00086 if(x < m_start) return 0.0;
00087 if(x > m_end) return 1.0;
00088 return (x - m_start) / (m_end - m_start);
00089 }
00090
00091 private:
00092 double m_start;
00093 double m_end;
00094 };
00095
00096
00097
00098 class gamma_multiply
00099 {
00100 public:
00101 gamma_multiply() : m_mul(1.0) {}
00102 gamma_multiply(double v) : m_mul(v) {}
00103
00104 void value(double v) { m_mul = v; }
00105 double value() const { return m_mul; }
00106
00107 double operator() (double x) const
00108 {
00109 double y = x * m_mul;
00110 if(y > 1.0) y = 1.0;
00111 return y;
00112 }
00113
00114 private:
00115 double m_mul;
00116 };
00117
00118 }
00119
00120 #endif
00121
00122
00123