1 /* === S Y N F I G ========================================================= */
2 /*! \file valuenode_twotone.cpp
3 ** \brief Implementation of the "Two-Tone" valuenode conversion.
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 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_twotone.h"
35 #include "valuenode_const.h"
42 /* === U S I N G =========================================================== */
46 using namespace synfig;
48 /* === M A C R O S ========================================================= */
50 /* === G L O B A L S ======================================================= */
52 /* === P R O C E D U R E S ================================================= */
54 /* === M E T H O D S ======================================================= */
56 synfig::ValueNode_TwoTone::ValueNode_TwoTone(const ValueBase &value):LinkableValueNode(synfig::ValueBase::TYPE_GRADIENT)
58 switch(value.get_type())
60 case ValueBase::TYPE_GRADIENT:
61 set_link("color1",ValueNode_Const::create(value.get(Gradient())(0)));
62 set_link("color2",ValueNode_Const::create(value.get(Gradient())(1)));
65 throw Exception::BadType(ValueBase::type_local_name(value.get_type()));
72 ValueNode_TwoTone::create_new()const
74 return new ValueNode_TwoTone(get_type());
78 ValueNode_TwoTone::create(const ValueBase& x)
80 return new ValueNode_TwoTone(x);
83 synfig::ValueNode_TwoTone::~ValueNode_TwoTone()
89 synfig::ValueNode_TwoTone::operator()(Time t)const
91 return Gradient((*ref_a)(t).get(Color()),(*ref_b)(t).get(Color()));
95 ValueNode_TwoTone::set_link_vfunc(int i,ValueNode::Handle value)
97 assert(i>=0 && i<link_count());
101 case 0: CHECK_TYPE_AND_SET_VALUE(ref_a, ValueBase::TYPE_COLOR);
102 case 1: CHECK_TYPE_AND_SET_VALUE(ref_b, ValueBase::TYPE_COLOR);
107 ValueNode::LooseHandle
108 ValueNode_TwoTone::get_link_vfunc(int i)const
110 assert(i>=0 && i<link_count());
123 ValueNode_TwoTone::link_count()const
129 ValueNode_TwoTone::link_local_name(int i)const
131 assert(i>=0 && i<link_count());
145 ValueNode_TwoTone::link_name(int i)const
147 assert(i>=0 && i<link_count());
161 ValueNode_TwoTone::get_link_index_from_name(const String &name)const
167 throw Exception::BadLinkName(name);
171 ValueNode_TwoTone::get_name()const
177 ValueNode_TwoTone::get_local_name()const
179 return _("Two-Tone");
183 ValueNode_TwoTone::check_type(ValueBase::Type type)
185 return type==ValueBase::TYPE_GRADIENT;