Skip to content

Commit

Permalink
fix dash glitch
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
luigi-rosso and luigi-rosso committed Sep 20, 2024
1 parent 3d8e05f commit c53e819
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8a974784d34fdd302cb0676d523d94cafe78f63e
d0d1dbf33ce951523011a03f909e7dfd7baf7765
12 changes: 9 additions & 3 deletions src/shapes/paint/dash_path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit c53e819

Please sign in to comment.