Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages | Examples

agg_gamma_functions.h

00001 //----------------------------------------------------------------------------
00002 // Anti-Grain Geometry - Version 2.2
00003 // Copyright (C) 2002-2004 Maxim Shemanarev (http://www.antigrain.com)
00004 //
00005 // Permission to copy, use, modify, sell and distribute this software 
00006 // is granted provided this copyright notice appears in all copies. 
00007 // This software is provided "as is" without express or implied
00008 // warranty, and with no claim as to its suitability for any purpose.
00009 //
00010 //----------------------------------------------------------------------------
00011 // Contact: mcseem@antigrain.com
00012 //          mcseemagg@yahoo.com
00013 //          http://www.antigrain.com
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     //===============================================================gamma_none
00025     struct gamma_none
00026     {
00027         double operator()(double x) const { return x; }
00028     };
00029 
00030 
00031     //==============================================================gamma_power
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     //==========================================================gamma_threshold
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     //============================================================gamma_linear
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     //==========================================================gamma_multiply
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 

Generated on Wed Feb 9 11:31:34 2005 for OpenGUI by  doxygen 1.4.0