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

SVG effect becomes "dim" on higher resolutions #840

Open
LaurenzV opened this issue Nov 2, 2024 · 2 comments
Open

SVG effect becomes "dim" on higher resolutions #840

LaurenzV opened this issue Nov 2, 2024 · 2 comments

Comments

@LaurenzV
Copy link
Contributor

LaurenzV commented Nov 2, 2024

Given the following SVG:

<svg id="svg1" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
    <title>lighting-color=hsla (SVG 2)</title>
    <desc>Looks like alpha should be ignored.</desc>

    <radialGradient id="rg1" r="0.5">
        <stop offset="0.5" stop-color="white"/>
        <stop offset="1" stop-color="black" stop-opacity="0"/>
    </radialGradient>
    <filter id="filter1" color-interpolation-filters="sRGB">
        <feSpecularLighting in="SourceAlpha" lighting-color="hsla(120, 100%, 25%, 0.5)"
                            specularConstant="8" specularExponent="10">
            <fePointLight x="100" y="100" z="10"/>
        </feSpecularLighting>
    </filter>
    <rect id="rect1" x="20" y="20" width="160" height="160"
          fill="url(#rg1)" filter="url(#filter1)"/>

    <!-- image frame -->
    <rect id="frame" x="1" y="1" width="198" height="198" fill="none" stroke="black"/>
</svg>

Rendering with cargo run -- test.svg test.png --background white yields the following result:
test

As you can see, there is a pretty clear white circle around the center.

Now I render with cargo run -- test.svg test.png --background white --zoom 4 and I get:
test

If you look closely, there is still a very dim white circle around it, but it's much less visible than before. Is this intended?

@LaurenzV
Copy link
Contributor Author

LaurenzV commented Nov 2, 2024

For what it's worth, it seems like the same happens in Firefox, but not in Chrome.

@RazrFalcon
Copy link
Collaborator

Lighting effects are effectively UB (undefined behavior) and every SVG library does whatever it wants.
Unless the SVG spec clarifies the expected behavior - we're out of luck.

If someone is willing to figure out what Chrome does differently - feel free to send a PR.

PS: A reminder, that SVG has non-reproducible rendering by design.

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

No branches or pull requests

2 participants