本文整理汇总了C++中Gradient::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Gradient::begin方法的具体用法?C++ Gradient::begin怎么用?C++ Gradient::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gradient
的用法示例。
在下文中一共展示了Gradient::begin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool
LinearGradient::compile_gradient(cairo_pattern_t* pattern, Gradient mygradient)const
{
bool loop=param_loop.get(bool());
bool zigzag=param_zigzag.get(bool());
bool cpoints_all_opaque=true;
float a,r,g,b;
Gradient::CPoint cp;
Gradient::const_iterator iter;
mygradient.sort();
if(zigzag)
{
Gradient zgradient;
for(iter=mygradient.begin();iter!=mygradient.end(); iter++)
{
cp=*iter;
cp.pos=cp.pos/2;
zgradient.push_back(cp);
}
for(iter=mygradient.begin();iter!=mygradient.end(); iter++)
{
cp=*iter;
cp.pos=1.0-cp.pos/2;
zgradient.push_back(cp);
}
mygradient=zgradient;
}
mygradient.sort();
if(loop)
{
cp=*mygradient.begin();
a=cp.color.get_a();
r=cp.color.get_r();
g=cp.color.get_g();
b=cp.color.get_b();
cairo_pattern_add_color_stop_rgba(pattern, 0.0, r, g, b, a);
}
for(iter=mygradient.begin();iter!=mygradient.end(); iter++)
{
cp=*iter;
a=cp.color.get_a();
r=cp.color.get_r();
g=cp.color.get_g();
b=cp.color.get_b();
cairo_pattern_add_color_stop_rgba(pattern, cp.pos, r, g, b, a);
if(a!=1.0) cpoints_all_opaque=false;
}
if(loop)
{
cp=*(--mygradient.end());
a=cp.color.get_a();
r=cp.color.get_r();
g=cp.color.get_g();
b=cp.color.get_b();
cairo_pattern_add_color_stop_rgba(pattern, 1.0, r, g, b, a);
}
return cpoints_all_opaque;
}
示例2: set
void Gradient::set(const Gradient& gradient)
{
// copy the gradient
resize(gradient.size());
copy(gradient.begin(), gradient.end(), begin());
//copy the norm and the valid_ flag
norm = gradient.norm;
inv_norm = gradient.inv_norm;
rms = gradient.rms;
valid_ = gradient.valid_;
}
示例3: offset
synfig::ValueBase
synfig::ValueNode_GradientRotate::operator()(Time t)const
{
if (getenv("SYNFIG_DEBUG_VALUENODE_OPERATORS"))
printf("%s:%d operator()\n", __FILE__, __LINE__);
Gradient gradient;
gradient=(*ref_gradient)(t).get(gradient);
Real offset((*ref_offset)(t).get(Real()));
Gradient::iterator iter;
for(iter=gradient.begin();iter!=gradient.end();++iter)
iter->pos+=offset;
return gradient;
}
示例4: count
synfig::ValueBase
synfig::ValueNode_Repeat_Gradient::operator()(Time t)const
{
if (getenv("SYNFIG_DEBUG_VALUENODE_OPERATORS"))
printf("%s:%d operator()\n", __FILE__, __LINE__);
const int count((*count_)(t).get(int()));
int i;
Gradient ret;
if(count<=0)
return ret;
const Gradient gradient((*gradient_)(t).get(Gradient()));
const float width(max(0.0,min(1.0,(*width_)(t).get(Real()))));
const bool specify_start((*specify_start_)(t).get(bool()));
const bool specify_end((*specify_end_)(t).get(bool()));
const float gradient_width_a(width/count);
const float gradient_width_b((1.0-width)/count);
Gradient::const_iterator iter;
Gradient::const_reverse_iterator riter;
if (specify_start)
ret.push_back(Gradient::CPoint(0,(*start_color_)(t).get(Color())));
for(i=0;i<count;i++)
{
float pos(float(i)/count);
if (width != 0.0)
for(iter=gradient.begin();iter!=gradient.end();iter++)
ret.push_back(Gradient::CPoint(pos+gradient_width_a*iter->pos,iter->color));
pos+=gradient_width_a;
if (width != 1.0)
for(riter=gradient.rbegin();riter!=gradient.rend();riter++)
ret.push_back(Gradient::CPoint(pos+gradient_width_b*(1-(riter->pos)),riter->color));
}
if (specify_end)
ret.push_back(Gradient::CPoint(1,(*end_color_)(t).get(Color())));
return ret;
}