mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-28 05:37:19 +00:00
Fix outline preview of contour tool.
The purpose of this fix is to correct the outline preview of the Contour Tool when: - is used with custom brush, - with alpha content, - and pixel perfect mode OFF. Before this fix, the outline was being printed more than twice in some places (only noticed with alpha content), giving a bad appearance.
This commit is contained in:
parent
be74723e37
commit
62802cfbdf
@ -68,47 +68,32 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class IntertwineAsLines : public Intertwine {
|
class IntertwineAsLines : public Intertwine {
|
||||||
Stroke m_lastPointPrinted;
|
|
||||||
Stroke m_pts;
|
Stroke m_pts;
|
||||||
|
|
||||||
void saveLastPointAndDoPointshape(ToolLoop* loop, const Stroke& stroke) {
|
|
||||||
m_lastPointPrinted = stroke;
|
|
||||||
doPointshapePoint(stroke[0].x, stroke[0].y, loop);
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool snapByAngle() override { return true; }
|
bool snapByAngle() override { return true; }
|
||||||
|
|
||||||
|
void prepareIntertwine() override {
|
||||||
|
m_pts.reset();
|
||||||
|
}
|
||||||
|
|
||||||
void joinStroke(ToolLoop* loop, const Stroke& stroke) override {
|
void joinStroke(ToolLoop* loop, const Stroke& stroke) override {
|
||||||
|
if (loop->getTracePolicy() == TracePolicy::Last)
|
||||||
|
m_pts.reset();
|
||||||
|
|
||||||
if (stroke.size() == 0)
|
if (stroke.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
else if (stroke.size() == 1) {
|
||||||
if (stroke.size() == 1) {
|
if (m_pts.empty())
|
||||||
saveLastPointAndDoPointshape(loop, stroke);
|
m_pts = stroke;
|
||||||
|
doPointshapePoint(stroke[0].x, stroke[0].y, loop);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (stroke.size() >= 2) {
|
|
||||||
if (stroke.size() == 2 && stroke[0] == stroke[1]) {
|
|
||||||
if (m_lastPointPrinted.empty()) {
|
|
||||||
saveLastPointAndDoPointshape(loop, stroke);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (m_lastPointPrinted[0] != stroke[0] ||
|
|
||||||
loop->getTracePolicy() == TracePolicy::Last) {
|
|
||||||
saveLastPointAndDoPointshape(loop, stroke);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
doc::AlgoLineWithAlgoPixel lineAlgo = getLineAlgo(loop);
|
doc::AlgoLineWithAlgoPixel lineAlgo = getLineAlgo(loop);
|
||||||
for (int c=0; c+1<stroke.size(); ++c) {
|
for (int c=0; c+1<stroke.size(); ++c) {
|
||||||
lineAlgo(
|
lineAlgo(stroke[c].x, stroke[c].y,
|
||||||
stroke[c].x,
|
stroke[c+1].x, stroke[c+1].y,
|
||||||
stroke[c].y,
|
|
||||||
stroke[c+1].x,
|
|
||||||
stroke[c+1].y,
|
|
||||||
(void*)&m_pts,
|
(void*)&m_pts,
|
||||||
(AlgoPixel)&addPointsWithoutDuplicatingLastOne);
|
(AlgoPixel)&addPointsWithoutDuplicatingLastOne);
|
||||||
}
|
}
|
||||||
@ -126,12 +111,6 @@ public:
|
|||||||
for (int c=start; c<m_pts.size(); ++c)
|
for (int c=start; c<m_pts.size(); ++c)
|
||||||
doPointshapePoint(m_pts[c].x, m_pts[c].y, loop);
|
doPointshapePoint(m_pts[c].x, m_pts[c].y, loop);
|
||||||
|
|
||||||
ASSERT(!m_lastPointPrinted.empty());
|
|
||||||
m_lastPointPrinted[0] = m_pts[m_pts.size()-1];
|
|
||||||
}
|
|
||||||
m_pts.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Closed shape (polygon outline)
|
// Closed shape (polygon outline)
|
||||||
// Note: Contour tool was getting into the condition with no need, so
|
// Note: Contour tool was getting into the condition with no need, so
|
||||||
// we add the && !isFreehand to detect this circunstance.
|
// we add the && !isFreehand to detect this circunstance.
|
||||||
@ -144,6 +123,7 @@ public:
|
|||||||
stroke[0].x, stroke[0].y, loop);
|
stroke[0].x, stroke[0].y, loop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void fillStroke(ToolLoop* loop, const Stroke& stroke) override {
|
void fillStroke(ToolLoop* loop, const Stroke& stroke) override {
|
||||||
if (stroke.size() < 3) {
|
if (stroke.size() < 3) {
|
||||||
|
@ -255,6 +255,10 @@ void ToolLoopManager::doLoopStep(bool lastStep)
|
|||||||
m_toolLoop->validateDstImage(gfx::Region(m_toolLoop->getDstImage()->bounds()));
|
m_toolLoop->validateDstImage(gfx::Region(m_toolLoop->getDstImage()->bounds()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (m_toolLoop->getBrush()->type() == kImageBrushType) {
|
||||||
|
m_toolLoop->invalidateDstImage();
|
||||||
|
m_toolLoop->validateDstImage(gfx::Region(m_toolLoop->getDstImage()->bounds()));
|
||||||
|
}
|
||||||
|
|
||||||
m_toolLoop->validateDstImage(m_dirtyArea);
|
m_toolLoop->validateDstImage(m_dirtyArea);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user