X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fgradient.h;h=fdba3df1218f7845cffcb08b7e209ba08550c960;hb=64591d2bbceaf68a64008a0044e2fef3454e44ac;hp=25a9dbfa84e86800ba1c30b578f0c93e003aaa4c;hpb=adefa78207f52170e40f8e9ab3525c2042b3ac93;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/gradient.h b/synfig-core/trunk/src/synfig/gradient.h index 25a9dbf..fdba3df 100644 --- a/synfig-core/trunk/src/synfig/gradient.h +++ b/synfig-core/trunk/src/synfig/gradient.h @@ -6,6 +6,7 @@ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007 Chris Moore ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -60,12 +61,18 @@ struct GradientCPoint : public UniqueID /*! \class Gradient ** \brief Color Gradient Class */ -class Gradient : public std::vector +using namespace std; +class Gradient { public: typedef GradientCPoint CPoint; + typedef vector CPointList; + typedef CPointList::const_iterator const_iterator; + typedef CPointList::iterator iterator; + typedef CPointList::const_reverse_iterator const_reverse_iterator; + typedef CPointList::reverse_iterator reverse_iterator; private: - + CPointList cpoints; public: Gradient() { } @@ -81,6 +88,30 @@ public: //! You should call this function after changing stuff. void sort(); + void push_back(const CPoint cpoint) { cpoints.push_back(cpoint); } + iterator erase(iterator iter) { return cpoints.erase(iter); } + bool empty()const { return cpoints.empty(); } + size_t size()const { return cpoints.size(); } + + iterator begin() { return cpoints.begin(); } + iterator end() { return cpoints.end(); } + reverse_iterator rbegin() { return cpoints.rbegin(); } + reverse_iterator rend() { return cpoints.rend(); } + const_iterator begin()const { return cpoints.begin(); } + const_iterator end()const { return cpoints.end(); } + const_reverse_iterator rbegin()const { return cpoints.rbegin(); } + const_reverse_iterator rend()const { return cpoints.rend(); } + + Gradient &operator+=(const Gradient &rhs); + Gradient &operator-=(const Gradient &rhs); + Gradient &operator*=(const float &rhs); + Gradient &operator/=(const float &rhs); + + Gradient operator+(const Gradient &rhs)const { return Gradient(*this)+=rhs; } + Gradient operator-(const Gradient &rhs)const { return Gradient(*this)-=rhs; } + Gradient operator*(const float &rhs)const { return Gradient(*this)*=rhs; } + Gradient operator/(const float &rhs)const { return Gradient(*this)/=rhs; } + Color operator()(const Real &x, float supersample=0)const; //! Returns the iterator of the CPoint closest to \a x