Skip to content

Parse clip-rule on the first child of clip-path element #325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

nguyenalter
Copy link
Contributor

@nguyenalter nguyenalter commented Mar 13, 2025

This PR solves the issue #324.

Previously, the clip-path element always clips with nonzero rule, for example:

<svg width="600" viewBox="0 0 600 600" xmlns="http://www.w3.org/2000/svg" version="1.1">
  <clipPath id="clip-evenodd">
   <!-- Setting `evenodd` here does not work  -->
    <path d="M30,10 h370 v70 h-370 v-70 M50,20 h100 v50 h-100 v-50 z" fill="none" stroke="red" clip-rule="evenodd"/>
  </clipPath>
  <line x1="30" y1="40" x2="400" y2="40" stroke="red" clip-path="url(#clip-evenodd)"/>
</svg>

New behavior: the clip-path will use the clip-rule attribute of the first child to determine which rules to clip the whole clip-path element. If there is no clip-rule specified in the child, use the clip-rule attribute from clip-path element directly.

Note: This PR does not handle different clip-rule values inside clip-path element.

@nguyenalter nguyenalter force-pushed the feat/clip-path-clip-rule-attribute branch from 0153a4d to 7e76b64 Compare March 13, 2025 16:51
@HackbrettXXX HackbrettXXX linked an issue Mar 18, 2025 that may be closed by this pull request
Copy link
Member

@HackbrettXXX HackbrettXXX left a comment

Choose a reason for hiding this comment

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

Thanks! The code looks good. Please revert the changes in the dist folder. The files are only updated on release.

@nguyenalter
Copy link
Contributor Author

Thank @HackbrettXXX, I reverted the changes.

Copy link
Member

@HackbrettXXX HackbrettXXX left a comment

Choose a reason for hiding this comment

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

Looks good.

@HackbrettXXX HackbrettXXX merged commit 3ca9c0c into yWorks:master Mar 18, 2025
1 check 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.

Using clipPath with evenodd clip-rule does not work
2 participants