1 /* === S I N F G =========================================================== */
3 ** \brief Color Gradient Class
5 ** $Id: gradient.h,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === S T A R T =========================================================== */
24 #ifndef __SINFG_GRADIENT_H
25 #define __SINFG_GRADIENT_H
27 /* === H E A D E R S ======================================================= */
35 /* === M A C R O S ========================================================= */
37 /* === T Y P E D E F S ===================================================== */
39 /* === C L A S S E S & S T R U C T S ======================================= */
43 /*! \struct GradientCPoint
46 struct GradientCPoint : public UniqueID
51 bool operator<(const GradientCPoint &rhs)const { return pos<rhs.pos; }
52 bool operator<(const Real &rhs)const { return pos<rhs; }
55 GradientCPoint(const Real &pos, const Color &color):pos(pos),color(color) { }
56 }; // END of class GradientCPoint
60 ** \brief Color Gradient Class
62 class Gradient : public std::vector<GradientCPoint>
65 typedef GradientCPoint CPoint;
71 //! Two-Tone Color Gradient Convience Constructor
72 Gradient(const Color &c1, const Color &c2);
74 //! Three-Tone Color Gradient Convience Constructor
75 Gradient(const Color &c1, const Color &c2, const Color &c3);
77 //! Alias for sort (Implemented for consistancy)
78 void sync() { sort(); }
80 //! You should call this function after changing stuff.
83 Color operator()(const Real &x, float supersample=0)const;
85 //! Returns the iterator of the CPoint closest to \a x
86 iterator proximity(const Real &x);
88 //! Returns the const_iterator of the CPoint closest to \a x
89 const_iterator proximity(const Real &x)const;
91 //! Returns the iterator of the CPoint with UniqueID \a id
92 iterator find(const UniqueID &id);
94 //! Returns the const_iterator of the CPoint with UniqueID \a id
95 const_iterator find(const UniqueID &id)const;
96 }; // END of class Gradient
98 }; // END of namespace sinfg
100 /* === E N D =============================================================== */