Color
synfig::Gradient::operator()(const Real &x,float supersample)const
{
- if(empty())
+ if(cpoints.empty())
return Color(0,0,0,0);
if(supersample<0)
supersample=-supersample;
float begin_sample(x-supersample*0.5);
float end_sample(x+supersample*0.5);
- if(size()==1 || end_sample<=front().pos || isnan(x))
- return front().color;
+ if(cpoints.size()==1 || end_sample<=cpoints.front().pos || isnan(x))
+ return cpoints.front().color;
- if(begin_sample>=back().pos)
- return back().color;
+ if(begin_sample>=cpoints.back().pos)
+ return cpoints.back().color;
/*
if(end_sample>=back().pos)
/*! \class Gradient
** \brief Color Gradient Class
*/
-class Gradient : public std::vector<GradientCPoint>
+using namespace std;
+class Gradient
{
public:
typedef GradientCPoint CPoint;
+ typedef vector<GradientCPoint>::const_iterator const_iterator;
+ typedef vector<GradientCPoint>::iterator iterator;
+ typedef vector<GradientCPoint>::const_reverse_iterator const_reverse_iterator;
+ typedef vector<GradientCPoint>::reverse_iterator reverse_iterator;
private:
-
+ vector<GradientCPoint> cpoints;
public:
Gradient() { }
//! You should call this function after changing stuff.
void sort();
+ void push_back(const GradientCPoint 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(); }
+
Color operator()(const Real &x, float supersample=0)const;
//! Returns the iterator of the CPoint closest to \a x