1 /* === S Y N F I G ========================================================= */
2 /*! \file valuenode_gradientrotate.cpp
3 ** \brief Implementation of the "Gradient Rotate" valuenode conversion.
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2007, 2008 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 /* ========================================================================= */
24 /* === H E A D E R S ======================================================= */
34 #include "valuenode_gradientrotate.h"
35 #include "valuenode_const.h"
41 /* === U S I N G =========================================================== */
45 using namespace synfig;
47 /* === M A C R O S ========================================================= */
49 /* === G L O B A L S ======================================================= */
51 /* === P R O C E D U R E S ================================================= */
53 /* === M E T H O D S ======================================================= */
55 synfig::ValueNode_GradientRotate::ValueNode_GradientRotate(const Gradient& x):
56 LinkableValueNode(synfig::ValueBase::TYPE_GRADIENT)
58 Vocab ret(get_children_vocab());
59 set_children_vocab(ret);
60 set_link("gradient",ValueNode_Const::create(x));
61 set_link("offset",ValueNode_Const::create(Real(0)));
65 ValueNode_GradientRotate::create_new()const
67 return new ValueNode_GradientRotate(Gradient());
70 ValueNode_GradientRotate*
71 ValueNode_GradientRotate::create(const ValueBase& x)
73 ValueBase::Type id(x.get_type());
74 if(id!=ValueBase::TYPE_GRADIENT)
77 throw runtime_error(String(_("Gradient Rotate"))+_(":Bad type ")+ValueBase::type_local_name(id));
80 ValueNode_GradientRotate* value_node=new ValueNode_GradientRotate(x.get(Gradient()));
82 assert(value_node->get_type()==id);
87 synfig::ValueNode_GradientRotate::~ValueNode_GradientRotate()
93 synfig::ValueNode_GradientRotate::operator()(Time t)const
95 if (getenv("SYNFIG_DEBUG_VALUENODE_OPERATORS"))
96 printf("%s:%d operator()\n", __FILE__, __LINE__);
99 gradient=(*ref_gradient)(t).get(gradient);
100 Real offset((*ref_offset)(t).get(Real()));
101 Gradient::iterator iter;
102 for(iter=gradient.begin();iter!=gradient.end();++iter)
109 ValueNode_GradientRotate::set_link_vfunc(int i,ValueNode::Handle value)
111 assert(i>=0 && i<link_count());
115 case 0: CHECK_TYPE_AND_SET_VALUE(ref_gradient, ValueBase::TYPE_GRADIENT);
116 case 1: CHECK_TYPE_AND_SET_VALUE(ref_offset, ValueBase::TYPE_REAL);
121 ValueNode::LooseHandle
122 ValueNode_GradientRotate::get_link_vfunc(int i)const
124 assert(i>=0 && i<link_count());
137 ValueNode_GradientRotate::get_name()const
139 return "gradient_rotate";
143 ValueNode_GradientRotate::get_local_name()const
145 return _("Gradient Rotate");
149 ValueNode_GradientRotate::check_type(ValueBase::Type type)
151 return type==ValueBase::TYPE_GRADIENT;
154 LinkableValueNode::Vocab
155 ValueNode_GradientRotate::get_children_vocab_vfunc()const
157 if(children_vocab.size())
158 return children_vocab;
160 LinkableValueNode::Vocab ret;
162 ret.push_back(ParamDesc(ValueBase(),"gradient")
163 .set_local_name(_("Gradient"))
164 .set_description(_("The source gradient to rotate"))
167 ret.push_back(ParamDesc(ValueBase(),"offset")
168 .set_local_name(_("Offset"))
169 .set_description(_("The amount to offset the gradient"))