From: dooglus Date: Mon, 14 Jan 2008 08:49:52 +0000 (+0000) Subject: Extend the Add and Subtract ValueNodes to work with gradients. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=f579c76cc5a4e8fabcd314699893e69ce09b6d99;p=synfig.git Extend the Add and Subtract ValueNodes to work with gradients. git-svn-id: http://svn.voria.com/code@1354 1f10aa63-cdf2-0310-b900-c93c546f37ac --- diff --git a/synfig-core/trunk/src/synfig/valuenode_add.cpp b/synfig-core/trunk/src/synfig/valuenode_add.cpp index 3843598..366b325 100644 --- a/synfig-core/trunk/src/synfig/valuenode_add.cpp +++ b/synfig-core/trunk/src/synfig/valuenode_add.cpp @@ -35,6 +35,7 @@ #include "valuenode_const.h" #include #include "color.h" +#include "gradient.h" #include "vector.h" #include "angle.h" #include "real.h" @@ -72,6 +73,10 @@ synfig::ValueNode_Add::ValueNode_Add(const ValueBase &value): set_link("lhs",ValueNode_Const::create(value.get(Color()))); set_link("rhs",ValueNode_Const::create(Color(0,0,0,0))); break; + case ValueBase::TYPE_GRADIENT: + set_link("lhs",ValueNode_Const::create(value.get(Gradient()))); + set_link("rhs",ValueNode_Const::create(Gradient())); + break; case ValueBase::TYPE_INTEGER: set_link("lhs",ValueNode_Const::create(value.get(int()))); set_link("rhs",ValueNode_Const::create(int(0))); @@ -122,6 +127,8 @@ synfig::ValueNode_Add::operator()(Time t)const return ((*ref_a)(t).get(Angle())+(*ref_b)(t).get(Angle()))*(*scalar)(t).get(Real()); case ValueBase::TYPE_COLOR: return ((*ref_a)(t).get(Color())+(*ref_b)(t).get(Color()))*(*scalar)(t).get(Real()); + case ValueBase::TYPE_GRADIENT: + return ((*ref_a)(t).get(Gradient())+(*ref_b)(t).get(Gradient()))*(*scalar)(t).get(Real()); case ValueBase::TYPE_INTEGER: return round_to_int(((*ref_a)(t).get(int())+(*ref_b)(t).get(int()))*(*scalar)(t).get(Real())); case ValueBase::TYPE_REAL: @@ -225,6 +232,7 @@ ValueNode_Add::check_type(ValueBase::Type type) { return type==ValueBase::TYPE_ANGLE || type==ValueBase::TYPE_COLOR + || type==ValueBase::TYPE_GRADIENT || type==ValueBase::TYPE_INTEGER || type==ValueBase::TYPE_REAL || type==ValueBase::TYPE_TIME diff --git a/synfig-core/trunk/src/synfig/valuenode_subtract.cpp b/synfig-core/trunk/src/synfig/valuenode_subtract.cpp index 50230e9..b3cbbaf 100644 --- a/synfig-core/trunk/src/synfig/valuenode_subtract.cpp +++ b/synfig-core/trunk/src/synfig/valuenode_subtract.cpp @@ -35,6 +35,7 @@ #include "valuenode_const.h" #include #include "color.h" +#include "gradient.h" #include "vector.h" #include "angle.h" #include "real.h" @@ -72,6 +73,10 @@ synfig::ValueNode_Subtract::ValueNode_Subtract(const ValueBase &value): set_link("lhs",ValueNode_Const::create(value.get(Color()))); set_link("rhs",ValueNode_Const::create(Color(0,0,0,0))); break; + case ValueBase::TYPE_GRADIENT: + set_link("lhs",ValueNode_Const::create(value.get(Gradient()))); + set_link("rhs",ValueNode_Const::create(Gradient())); + break; case ValueBase::TYPE_INTEGER: set_link("lhs",ValueNode_Const::create(value.get(int()))); set_link("rhs",ValueNode_Const::create(int(0))); @@ -128,6 +133,8 @@ synfig::ValueNode_Subtract::operator()(Time t)const return ((*ref_a)(t).get(Angle())-(*ref_b)(t).get(Angle()))*(*scalar)(t).get(Real()); case ValueBase::TYPE_COLOR: return ((*ref_a)(t).get(Color())-(*ref_b)(t).get(Color()))*(*scalar)(t).get(Real()); + case ValueBase::TYPE_GRADIENT: + return ((*ref_a)(t).get(Gradient())-(*ref_b)(t).get(Gradient()))*(*scalar)(t).get(Real()); case ValueBase::TYPE_INTEGER: return round_to_int(((*ref_a)(t).get(int())-(*ref_b)(t).get(int()))*(*scalar)(t).get(Real())); case ValueBase::TYPE_REAL: @@ -231,6 +238,7 @@ ValueNode_Subtract::check_type(ValueBase::Type type) { return type==ValueBase::TYPE_ANGLE || type==ValueBase::TYPE_COLOR + || type==ValueBase::TYPE_GRADIENT || type==ValueBase::TYPE_INTEGER || type==ValueBase::TYPE_REAL || type==ValueBase::TYPE_TIME