/* === S Y N F I G ========================================================= */
/*! \file valuenode_scale.cpp
-** \brief Template File
+** \brief Implementation of the "Scale" valuenode conversion.
**
** $Id$
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007 Chris Moore
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
#include "valuenode_scale.h"
#include "valuenode_const.h"
#include <stdexcept>
-#include <cassert>
#include "color.h"
#include "vector.h"
#include "time.h"
#include "angle.h"
+#include <ETL/misc>
#endif
break;
default:
assert(0);
- throw runtime_error("synfig::ValueNode_Scale:Bad type "+ValueBase::type_name(value.get_type()));
+ throw runtime_error(_("synfig::ValueNode_Scale:Bad type ")+ValueBase::type_local_name(value.get_type()));
}
assert(value_node);
return ret;
}
else if(get_type()==ValueBase::TYPE_INTEGER)
- {
- Real ret = (*value_node)(t).get(int())*(*scalar)(t).get(Real()) + 0.5f;
- if (ret < 0) return static_cast<int>(ret-1);
- return static_cast<int>(ret);
- }
+ return round_to_int((*value_node)(t).get(int())*(*scalar)(t).get(Real()));
else if(get_type()==ValueBase::TYPE_REAL)
return (*value_node)(t).get(Real())*(*scalar)(t).get(Real());
else if(get_type()==ValueBase::TYPE_TIME)
bool
ValueNode_Scale::set_link_vfunc(int i,ValueNode::Handle x)
{
- if(!(i==0 || i==1))
- return false;
+ assert(i>=0 && i<link_count());
if(i==0 && !set_value_node(x))
return false;
ValueNode::LooseHandle
ValueNode_Scale::get_link_vfunc(int i)const
{
- assert(i==0 || i==1);
+ assert(i>=0 && i<link_count());
+
if(i==0)
return value_node;
else if(i==1)
String
ValueNode_Scale::link_local_name(int i)const
{
- assert(i==0 || i==1);
+ assert(i>=0 && i<link_count());
+
if(i==0)
return _("Link");
else if(i==1)
String
ValueNode_Scale::link_name(int i)const
{
- assert(i==0 || i==1);
+ assert(i>=0 && i<link_count());
+
if(i==0)
return "link";
else if(i==1)