From: dooglus Date: Sat, 15 Sep 2007 20:06:08 +0000 (+0000) Subject: Partially fix 1568818: Declare mathematical operators so that we can animate gradient... X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=2bcfb246cd9568429230b0c996a26e8deebda348;p=synfig.git Partially fix 1568818: Declare mathematical operators so that we can animate gradients over time. git-svn-id: http://svn.voria.com/code@674 1f10aa63-cdf2-0310-b900-c93c546f37ac --- diff --git a/synfig-core/trunk/src/synfig/gradient.h b/synfig-core/trunk/src/synfig/gradient.h index bc4c1e8..5e74ddc 100644 --- a/synfig-core/trunk/src/synfig/gradient.h +++ b/synfig-core/trunk/src/synfig/gradient.h @@ -65,12 +65,13 @@ class Gradient { public: typedef GradientCPoint CPoint; - typedef vector::const_iterator const_iterator; - typedef vector::iterator iterator; - typedef vector::const_reverse_iterator const_reverse_iterator; - typedef vector::reverse_iterator reverse_iterator; + 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: - vector cpoints; + CPointList cpoints; public: Gradient() { } @@ -86,7 +87,7 @@ public: //! You should call this function after changing stuff. void sort(); - void push_back(const GradientCPoint cpoint) { cpoints.push_back(cpoint); } + 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(); } @@ -100,6 +101,16 @@ public: 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