Skip to content

Comments

Fix incorrect miter clip length#929

Merged
nical merged 3 commits intonical:mainfrom
nickyfahey:miter-limit-fix
Apr 17, 2025
Merged

Fix incorrect miter clip length#929
nical merged 3 commits intonical:mainfrom
nickyfahey:miter-limit-fix

Conversation

@nickyfahey
Copy link
Contributor

If I'm understanding it correctly MiterClip should clip at a distance of the miter limit multiplied by the stroke width, but at the moment it actually clips to a quarter of this because the half width is being halved again instead of doubled in the clip distance calculation.

Possibly related to #923 but I could not reproduce the bug exactly as described (falling back to bevel as opposed to just getting the clip length wrong).

Before fix:
miter-limit-bug-before

After fix:
miter-limit-bug-after

Copy link
Owner

@nical nical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

According to the SVG spec:

the miter is clipped by a line perpendicular to the line bisecting the angle between the two path segments at a distance of half the value of miter length from the intersection of the two path segments.

So unless I missed something, lyon currently clips at half of the correct distance (oops), and your change makes it clip at twice the correct distance.

The fix should be:

get_clip_intersections(n0, n1, normal, miter_limit * join.half_width);

@nickyfahey
Copy link
Contributor Author

@nical Woops, looks like I was looking at the SVG 1 spec. Fixed it now.

Copy link
Owner

@nical nical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@nical nical merged commit 8f71592 into nical:main Apr 17, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants