Skip to content
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

Wrong <mask> bounds (x, y, widht, height) with the default maskUnits=objectBoundingBox #75

Closed
stanio opened this issue Mar 25, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@stanio
Copy link

stanio commented Mar 25, 2024

maskUnits:

For <mask>, maskUnits defines the coordinate system in use for the geometry attributes (x, y, width and height) of the element.

objectBoundingBox

This value indicates that all coordinates for the geometry attributes represent fractions or percentages of the bounding box of the element to which the mask is applied.

Seems like fraction values are interpreted as values in the user coordinate system, instead:

mask-bounds.svg:
<svg xmlns="http://www.w3.org/2000/svg"
    width="100" height="100" viewBox="0 0 100 100">

  <defs>
    <mask id="myMask" maskContentUnits="objectBoundingBox"
        x="-0.5" y="-0.5" width="2" height="2">
      <rect x="-0.5" y="-0.5" width="1" height="1" fill="white" />
    </mask>
  </defs>

  <rect x="15" y="15" width="160" height="160" mask="url(#myMask)"
      fill="white" stroke="blue" stroke-width="20" />

</svg>
Actual Expected
actual expected
@stanio
Copy link
Author

stanio commented Mar 25, 2024

Alternatively, percentages work fine:

     <mask id="myMask" maskContentUnits="objectBoundingBox"
-        x="-0.5" y="-0.5" width="2" height="2">
+        x="-50%" y="-50%" width="200%" height="200%">

weisJ added a commit that referenced this issue Mar 25, 2024
@weisJ weisJ added the bug Something isn't working label Mar 25, 2024
weisJ added a commit that referenced this issue Mar 25, 2024
@weisJ
Copy link
Owner

weisJ commented Jun 6, 2024

This should be fixed in the latest snapshot version.

@stanio
Copy link
Author

stanio commented Jun 6, 2024

Confirming it works for me using the current 1.5.0-SNAPSHOT.

@weisJ
Copy link
Owner

weisJ commented Jun 7, 2024

Version 1.5.0 has been released

@weisJ weisJ closed this as completed Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants