weisJ / jsvg

Java SVG renderer
MIT License
139 stars 9 forks source link

`<mask>` area doesn't get expanded beyond object's bounding box #65

Closed stanio closed 8 months ago

stanio commented 9 months ago

It appears <mask> area doesn't get expanded beyond the bounding box of the object it is applied to:

It could "shrink" inside the object's bounding box, though. The most apparent effect is that a stroke that goes beyond the object's bounding box gets clipped from view.

mask-0.svg

    <mask id="aperture" maskUnits="userSpaceOnUse"
        x="0" y="0" width="500" height="500">
Actual Expected
jsvg-mask-0 chrome-mask-0

mask-1.svg

    <mask id="aperture" maskUnits="userSpaceOnUse"
        x="50" y="50" width="450" height="450">
Actual Expected
jsvg-mask-1 chrome-mask-1

mask-2.svg

    <mask id="aperture" maskUnits="userSpaceOnUse"
        x="60" y="60" width="440" height="440">
Actual Expected
jsvg-mask-2 chrome-mask-2

Initially found in https://github.com/weisJ/jsvg/issues/64#issuecomment-1974806550

weisJ commented 9 months ago

This should be fixed in the latest snapshot

stanio commented 9 months ago

Trying out current 1.5.0-SNAPSHOT (gradlew --refresh-dependencies1.5.0-20240304.002615-19) – the outer stroke is now fully visible but a different defect appears. Looks like the overall mask is scaled (enlarged):

mask-0 mask-1 mask-2
mask-0 mask-1 mask-2

Notice the circular hole is bigger than the debug overlay that uses the same path as for the mask. A thick semi-transparent ring is also visible.

weisJ commented 9 months ago

This is related to #66. I have a fix locally, will push once #67 is resolved. I noticed that the library I am using to compare images in tests doesn’t handle transparent pixels and thus multiple tests have failed silently for the past few versions. I need to catch up with those before work on subpixel alignment can be continued.

stanio commented 8 months ago

Just tried with a current 1.5.0-SNAPSHOT – it now (currently) appears just right.