New "overlap" trace-policy for tools like Spray, Blur, and Jumble.

This commit is contained in:
David Capello 2010-12-11 21:49:44 -03:00
parent 06403f3ace
commit dbebaec92b
4 changed files with 15 additions and 4 deletions

View File

@ -443,7 +443,7 @@
ink="paint"
controller="freehand"
pointshape="spray"
tracepolicy="accumulative"
tracepolicy="overlap"
/>
</group>
@ -578,7 +578,7 @@
controller="freehand"
pointshape="pen"
intertwine="as_lines"
tracepolicy="accumulative"
tracepolicy="overlap"
default_pen_size="16"
/>
<tool id="jumble"
@ -587,7 +587,7 @@
controller="freehand"
pointshape="pen"
intertwine="as_lines"
tracepolicy="accumulative"
tracepolicy="overlap"
default_pen_size="16"
/>
</group>

View File

@ -215,13 +215,21 @@ void ToolLoopManager::doLoopStep(bool last_step)
switch (m_toolLoop->getTracePolicy()) {
case TOOL_TRACE_POLICY_ACCUMULATE:
// do nothing
// Do nothing. We accumulate traces in the destination image.
break;
case TOOL_TRACE_POLICY_LAST:
// Copy source to destination (reset the previous trace). Useful
// for tools like Line and Ellipse tools (we kept the last trace only).
image_clear(m_toolLoop->getDstImage(), 0);
image_copy(m_toolLoop->getDstImage(), m_toolLoop->getSrcImage(), 0, 0);
break;
case TOOL_TRACE_POLICY_OVERLAP:
// Copy destination to source (yes, destination to source). In
// this way each new trace overlaps the previous one.
image_copy(m_toolLoop->getSrcImage(), m_toolLoop->getDstImage(), 0, 0);
break;
}
// Get the modified area in the sprite with this intertwined set of points

View File

@ -51,6 +51,7 @@ enum ToolTracePolicy
{
TOOL_TRACE_POLICY_ACCUMULATE,
TOOL_TRACE_POLICY_LAST,
TOOL_TRACE_POLICY_OVERLAP,
};
// Class used to paint directly in the destination image (loop->getDstImage())

View File

@ -224,6 +224,8 @@ void ToolBox::loadToolProperties(TiXmlElement* xmlTool, Tool* tool, int button,
tracepolicy_value = TOOL_TRACE_POLICY_ACCUMULATE;
else if (strcmp(tracepolicy, "last") == 0)
tracepolicy_value = TOOL_TRACE_POLICY_LAST;
else if (strcmp(tracepolicy, "overlap") == 0)
tracepolicy_value = TOOL_TRACE_POLICY_OVERLAP;
else
throw ase_exception("Invalid trace-policy '%s' specified in '%s' tool.\n", tracepolicy, tool_id);
}