From 34250a145f44d753918027afd03631651e412aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Capello?= Date: Wed, 19 May 2021 17:27:01 -0300 Subject: [PATCH] Fix wrapPositionOnTiledMode to avoid having any edge of the point shape area outside of the canvas. When some of the edges of the point shape area is outside of the canvas the collapseRegionByTiledMode doesn't include the rects that were outside of the canvas. --- src/app/ui/editor/tool_loop_impl.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/app/ui/editor/tool_loop_impl.cpp b/src/app/ui/editor/tool_loop_impl.cpp index 18911d67d..10f9a0657 100644 --- a/src/app/ui/editor/tool_loop_impl.cpp +++ b/src/app/ui/editor/tool_loop_impl.cpp @@ -830,16 +830,28 @@ private: void wrapPositionOnTiledMode(const tools::Stroke::Pt& pt, tools::Stroke::Pt& result) { result = pt; + if (getTiledMode() == TiledMode::NONE) + return; + if (int(getTiledMode()) & int(TiledMode::X_AXIS)) { result.x %= m_editor->canvasSize().w; - if (result.x < 0) - result.x += m_editor->canvasSize().w; } if (int(getTiledMode()) & int(TiledMode::Y_AXIS)) { result.y %= m_editor->canvasSize().h; - if (result.y < 0) - result.y += m_editor->canvasSize().h; } + + gfx::Rect r; + getPointShape()->getModifiedArea(this, result.x, result.y, r); + + if (r.x < 0) + result.x += m_sprite->width(); + else if (r.x2() > m_editor->canvasSize().w) + result.x -= m_sprite->width(); + + if (r.y < 0) + result.y += m_sprite->height(); + else if (r.y2() > m_editor->canvasSize().h) + result.y -= m_sprite->height(); } };