00001 /* === S Y N F I G ========================================================= */ 00021 /* ========================================================================= */ 00022 00023 /* === S T A R T =========================================================== */ 00024 00025 #ifndef __SYNFIG_GRADIENT_H 00026 #define __SYNFIG_GRADIENT_H 00027 00028 /* === H E A D E R S ======================================================= */ 00029 00030 #include "real.h" 00031 #include "color.h" 00032 #include <vector> 00033 #include <utility> 00034 #include "uniqueid.h" 00035 00036 /* === M A C R O S ========================================================= */ 00037 00038 /* === T Y P E D E F S ===================================================== */ 00039 00040 /* === C L A S S E S & S T R U C T S ======================================= */ 00041 00042 namespace synfig { 00043 00047 struct GradientCPoint : public UniqueID 00048 { 00049 Real pos; 00050 Color color; 00051 00052 bool operator<(const GradientCPoint &rhs)const { return pos<rhs.pos; } 00053 bool operator<(const Real &rhs)const { return pos<rhs; } 00054 00055 GradientCPoint() { } 00056 GradientCPoint(const Real &pos, const Color &color):pos(pos),color(color) { } 00057 }; // END of class GradientCPoint 00058 00059 00063 class Gradient : public std::vector<GradientCPoint> 00064 { 00065 public: 00066 typedef GradientCPoint CPoint; 00067 private: 00068 00069 public: 00070 Gradient() { } 00071 00073 Gradient(const Color &c1, const Color &c2); 00074 00076 Gradient(const Color &c1, const Color &c2, const Color &c3); 00077 00079 void sync() { sort(); } 00080 00082 void sort(); 00083 00084 Color operator()(const Real &x, float supersample=0)const; 00085 00087 iterator proximity(const Real &x); 00088 00090 const_iterator proximity(const Real &x)const; 00091 00093 iterator find(const UniqueID &id); 00094 00096 const_iterator find(const UniqueID &id)const; 00097 }; // END of class Gradient 00098 00099 }; // END of namespace synfig 00100 00101 /* === E N D =============================================================== */ 00102 00103 #endif