#include "valuenode_repeat_gradient.h"
#include "valuenode_const.h"
#include <stdexcept>
#include "valuenode_repeat_gradient.h"
#include "valuenode_const.h"
#include <stdexcept>
#include "gradient.h"
#endif
#include "gradient.h"
#endif
set_link("gradient",ValueNode_Const::create(Gradient()));
set_link("count",count_=ValueNode_Const::create(int(3)));
set_link("width",ValueNode_Const::create(0.5));
set_link("gradient",ValueNode_Const::create(Gradient()));
set_link("count",count_=ValueNode_Const::create(int(3)));
set_link("width",ValueNode_Const::create(0.5));
+ set_link("specify_start",ValueNode_Const::create(true));
+ set_link("specify_end",ValueNode_Const::create(true));
+ set_link("start_color",ValueNode_Const::create(Color::alpha()));
+ set_link("end_color",ValueNode_Const::create(Color::alpha()));
+bool
+synfig::ValueNode_Repeat_Gradient::set_specify_start(ValueNode::Handle a)
+{
+ if(a->get_type()!=ValueBase::TYPE_BOOL)
+ return false;
+ specify_start_=a;
+ return true;
+}
+
+bool
+synfig::ValueNode_Repeat_Gradient::set_specify_end(ValueNode::Handle a)
+{
+ if(a->get_type()!=ValueBase::TYPE_BOOL)
+ return false;
+ specify_end_=a;
+ return true;
+}
+
+bool
+synfig::ValueNode_Repeat_Gradient::set_start_color(ValueNode::Handle a)
+{
+ if(a->get_type()!=ValueBase::TYPE_COLOR)
+ return false;
+ start_color_=a;
+ return true;
+}
+
+bool
+synfig::ValueNode_Repeat_Gradient::set_end_color(ValueNode::Handle a)
+{
+ if(a->get_type()!=ValueBase::TYPE_COLOR)
+ return false;
+ end_color_=a;
+ return true;
+}
+
synfig::ValueBase
synfig::ValueNode_Repeat_Gradient::operator()(Time t)const
{
synfig::ValueBase
synfig::ValueNode_Repeat_Gradient::operator()(Time t)const
{
const Gradient gradient((*gradient_)(t).get(Gradient()));
const float width(max(0.0,min(1.0,(*width_)(t).get(Real()))));
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;
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);
for(i=0;i<count;i++)
{
float pos(float(i)/count);
for(riter=gradient.rbegin();riter!=gradient.rend();riter++)
ret.push_back(Gradient::CPoint(pos+gradient_width_b*(1-(riter->pos)),riter->color));
}
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())));
case 2:
if(set_width(x)) { signal_child_changed()(i);signal_value_changed()(); return true; }
else { return false; }
case 2:
if(set_width(x)) { signal_child_changed()(i);signal_value_changed()(); return true; }
else { return false; }
+ case 3:
+ if(set_specify_start(x)) { signal_child_changed()(i);signal_value_changed()(); return true; }
+ else { return false; }
+ case 4:
+ if(set_specify_end(x)) { signal_child_changed()(i);signal_value_changed()(); return true; }
+ else { return false; }
+ case 5:
+ if(set_start_color(x)) { signal_child_changed()(i);signal_value_changed()(); return true; }
+ else { return false; }
+ case 6:
+ if(set_end_color(x)) { signal_child_changed()(i);signal_value_changed()(); return true; }
+ else { return false; }
case 0: return gradient_;
case 1: return count_;
case 2: return width_;
case 0: return gradient_;
case 1: return count_;
case 2: return width_;
+ case 3: return specify_start_;
+ case 4: return specify_end_;
+ case 5: return start_color_;
+ case 6: return end_color_;
int
ValueNode_Repeat_Gradient::link_count()const
{
int
ValueNode_Repeat_Gradient::link_count()const
{
case 0: return _("Gradient");
case 1: return _("Count");
case 2: return _("Width");
case 0: return _("Gradient");
case 1: return _("Count");
case 2: return _("Width");
+ case 3: return _("Specify Start");
+ case 4: return _("Specify End");
+ case 5: return _("Start Color");
+ case 6: return _("End Color");
default: return String();
}
}
default: return String();
}
}
case 0: return "gradient";
case 1: return "count";
case 2: return "width";
case 0: return "gradient";
case 1: return "count";
case 2: return "width";
+ case 3: return "specify_start";
+ case 4: return "specify_end";
+ case 5: return "start_color";
+ case 6: return "end_color";
default: return String();
}
}
default: return String();
}
}
if(name=="gradient") return 0;
if(name=="count") return 1;
if(name=="width") return 2;
if(name=="gradient") return 0;
if(name=="count") return 1;
if(name=="width") return 2;
+ if(name=="specify_start") return 3;
+ if(name=="specify_end") return 4;
+ if(name=="start_color") return 5;
+ if(name=="end_color") return 6;
throw Exception::BadLinkName(name);
}
throw Exception::BadLinkName(name);
}
ValueNode::RHandle gradient_;
ValueNode::RHandle count_;
ValueNode::RHandle width_;
ValueNode::RHandle gradient_;
ValueNode::RHandle count_;
ValueNode::RHandle width_;
+ ValueNode::RHandle specify_start_;
+ ValueNode::RHandle specify_end_;
+ ValueNode::RHandle start_color_;
+ ValueNode::RHandle end_color_;
ValueNode::Handle get_count()const { return count_; }
bool set_width(ValueNode::Handle x);
ValueNode::Handle get_count()const { return count_; }
bool set_width(ValueNode::Handle x);
+ bool set_specify_start(ValueNode::Handle a);
+ bool set_specify_end(ValueNode::Handle a);
+ bool set_start_color(ValueNode::Handle a);
+ bool set_end_color(ValueNode::Handle a);
virtual bool set_link_vfunc(int i,ValueNode::Handle x);
virtual bool set_link_vfunc(int i,ValueNode::Handle x);