mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-20 18:40:57 +00:00
Fix joinStroke function from class IntertwineAsLines
The purpose of this fix is draw correctly the first stroke point as result of a joinStroke() execution from class IntertwineAsLines when following conditions are meet: - pencil tool - pixel perfect OFF, - custom brush - try to draw a line of 2 pixel. The original issue was detected by the tests functions based in useTool function on Lua scripts. The issue was presented in tool.lua.
This commit is contained in:
parent
45a09f1a15
commit
8281e49798
@ -68,6 +68,11 @@ public:
|
||||
};
|
||||
|
||||
class IntertwineAsLines : public Intertwine {
|
||||
// It was introduced to know if joinStroke function
|
||||
// was executed inmediatelly after a "Last" trace policy (i.e. after the
|
||||
// user confirms a line draw while he is holding down the SHIFT key), so
|
||||
// we have to ignore printing the first pixel of the line.
|
||||
bool m_retainedTracePolicyLast = false;
|
||||
Stroke m_pts;
|
||||
|
||||
public:
|
||||
@ -75,11 +80,19 @@ public:
|
||||
|
||||
void prepareIntertwine() override {
|
||||
m_pts.reset();
|
||||
m_retainedTracePolicyLast = false;
|
||||
}
|
||||
|
||||
void joinStroke(ToolLoop* loop, const Stroke& stroke) override {
|
||||
if (loop->getTracePolicy() == TracePolicy::Last)
|
||||
// Required for LineFreehand controller in the first stage, when
|
||||
// we are drawing the line and the trace policy is "Last". Each
|
||||
// new joinStroke() is like a fresh start. Without this fix, the
|
||||
// first stage on LineFreehand will draw a "star" like pattern
|
||||
// with lines from the first point to the last point.
|
||||
if (loop->getTracePolicy() == TracePolicy::Last) {
|
||||
m_retainedTracePolicyLast = true;
|
||||
m_pts.reset();
|
||||
}
|
||||
|
||||
if (stroke.size() == 0)
|
||||
return;
|
||||
@ -106,7 +119,8 @@ public:
|
||||
// TODO useful only in the case when brush size = 1px
|
||||
const int start =
|
||||
(loop->getController()->isFreehand() &&
|
||||
!loop->getFilled() ? 1: 0);
|
||||
!loop->getFilled() &&
|
||||
m_retainedTracePolicyLast ? 1: 0);
|
||||
|
||||
for (int c=start; c<m_pts.size(); ++c)
|
||||
doPointshapePoint(m_pts[c].x, m_pts[c].y, loop);
|
||||
|
Loading…
x
Reference in New Issue
Block a user