Skip to content

Commit

Permalink
Commented that weird blob of code
Browse files Browse the repository at this point in the history
  • Loading branch information
lemmabit committed Aug 9, 2015
1 parent 276a1d6 commit 583db75
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion synfig-core/src/synfig/valuenodes/valuenode_reverse.cpp
Expand Up @@ -145,12 +145,15 @@ reverse_value(const ValueBase &value)

if(type == type_list)
{
// We'll be writing to this later, so copy it.
ValueBase v = value;
const ValueBase::List &list = v.get_list();
ValueBase::List out;
Type &c_type(v.get_contained_type());
if(ValueNode_Reverse::check_type(c_type))
{
// This is a "deep" reversal, so reverse the elements of the list, too.

out.reserve(list.size());

if(!v.get_loop())
Expand All @@ -162,6 +165,9 @@ reverse_value(const ValueBase &value)
}
else
{
// The reversal of a looped list is rotated to end with the same value as the original.
// This makes some things work better, e.g. makes an adv. outline come out looking the same
// after having both its vertices and its width points reversed.
for(ValueBase::List::const_reverse_iterator it=++list.rbegin(),end=list.rend(); it!=end; ++it)
{
out.push_back(reverse_value(*it));
Expand All @@ -171,6 +177,7 @@ reverse_value(const ValueBase &value)

if(c_type == type_dash_item)
{
// Dash items need to exchange offsets with their neighbors to work right.
Real prev = out.back().get(DashItem()).get_offset();
for(ValueBase::List::iterator it=out.begin(),end=out.end(); it!=end; ++it)
{
Expand All @@ -184,6 +191,7 @@ reverse_value(const ValueBase &value)
}
else
{
// The elements aren't reversible. Just copy them.
out.resize(list.size());
std::reverse_copy(list.begin(), list.end(), out.begin());
}
Expand Down Expand Up @@ -212,7 +220,7 @@ reverse_value(const ValueBase &value)
Gradient out;
for(Gradient::const_reverse_iterator it=grad.rbegin(),end=grad.rend(); it!=end; ++it)
{
out.push_back(GradientCPoint(1 - it->pos, it->color));
out.push_back(GradientCPoint(1-it->pos, it->color));
}
return out;
}
Expand Down

0 comments on commit 583db75

Please sign in to comment.