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

Global rotation inconsistent with chrome #874

Open
jermy opened this issue Dec 27, 2024 · 4 comments
Open

Global rotation inconsistent with chrome #874

jermy opened this issue Dec 27, 2024 · 4 comments

Comments

@jermy
Copy link

jermy commented Dec 27, 2024

I've got a small SVG reproduction of an issue I've seen where feOffset is used to create a drop shadow, but it turns out to be inconsistent when rotated - the global transform doesn't seem to be applied to the offset, so the positioning of the offset image is wrong.

<svg height="1000" width="1000" transform="rotate(45)" xmlns="http://www.w3.org/2000/svg">
   <rect x="400" y="100" width="200" height="100" fill="black" filter="url(#myFilter)" />
   <defs>
      <filter id="myFilter" x="0" y="0" width="800" height="600" filterUnits="userSpaceOnUse">
         <feOffset in="SourceGraphic" dy="200" result="offsetImage" />
         <feBlend in="SourceGraphic" in2="offsetImage" />
      </filter>
   </defs>
</svg>

I've done the above with a couple of different values of rotate(N), across a couple of different renderers. Image were rendered to 400px, and scaled down to 200px square in the table markdown below:

rotation resvg Gimp (rsvg) Chrome
0
20
45
Seemingly rotating each item independently then applying the offset The offset seems correctly modified, but centre of rotation isn't I assume this is correct - and that it is rotated around the centre of the image?

There's probably a second bug/inconsistency relating to the centre of rotation. I think all of the above are identical if transformed with rotate(N 0 0), so have different ideas of what 0,0 is.

I haven't quite worked out which bit of code should be handling such adjustments - assuming it's part of is it something that should be done by convert_offset, or does this relate to the TODO: Wrong! Does not account rotate and skew in resolve_primitive_region?

@RazrFalcon
Copy link
Collaborator

Complex transforms on filters are not supported.

@jermy
Copy link
Author

jermy commented Dec 27, 2024

What general changes would be needed to support them? And do you have an idea of which rotation origin is correct?

@RazrFalcon
Copy link
Collaborator

I have no idea how to implement them. Would probably require lots of significant changes to how filters are rendered.
It's a very old issue: #254

And do you have an idea of which rotation origin is correct?

Filters with transform is effectively undocumented in SVG, so I have absolutely no idea either. But in general we always follow Chrome, since it has the best SVG support in general.

@RazrFalcon
Copy link
Collaborator

Welcome to SVG:

filter-ts

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