From c53e819ed4392b9fc774c0a00d256bdf4c4822e6 Mon Sep 17 00:00:00 2001 From: luigi-rosso Date: Fri, 20 Sep 2024 20:21:32 +0000 Subject: [PATCH] fix dash glitch if we were right at the end of the contour we'd extract a 0 length segment with a moveto causing this: ![image](https://github.com/user-attachments/assets/9be8be98-b4f3-4ddd-b8ba-adb217cf589a) Diffs= d0d1dbf33 fix dash glitch (#8188) Co-authored-by: Luigi Rosso --- .rive_head | 2 +- src/shapes/paint/dash_path.cpp | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.rive_head b/.rive_head index 0a587c48..6203c76b 100644 --- a/.rive_head +++ b/.rive_head @@ -1 +1 @@ -8a974784d34fdd302cb0676d523d94cafe78f63e +d0d1dbf33ce951523011a03f909e7dfd7baf7765 diff --git a/src/shapes/paint/dash_path.cpp b/src/shapes/paint/dash_path.cpp index 26bbb82c..3b3cb7e9 100644 --- a/src/shapes/paint/dash_path.cpp +++ b/src/shapes/paint/dash_path.cpp @@ -11,7 +11,6 @@ float Dash::normalizedValue(float length) const { float right = m_percentage ? 1.0f : length; float p = fmodf(m_value, right); - fprintf(stderr, "Normalized value: %f | %f %f\n", p, m_value, m_percentage ? 1.0f : length); if (p < 0.0f) { p += right; @@ -87,8 +86,15 @@ RenderPath* PathDasher::dash(const RawPath& source, endLength -= contour->length(); if (draw) { - contour->getSegment(distance, contour->length(), &m_rawPath, true); - contour->getSegment(0.0f, endLength, &m_rawPath, !contour->isClosed()); + if (distance < contour->length()) + { + contour->getSegment(distance, contour->length(), &m_rawPath, true); + contour->getSegment(0.0f, endLength, &m_rawPath, !contour->isClosed()); + } + else + { + contour->getSegment(0.0f, endLength, &m_rawPath, true); + } } // Setup next step.