linebender / linebender/resvg

Global rotation inconsistent with chrome

Open
#874 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
4.1k
Forks
348
Avg merge
1d 14h
Merged PRs (30d)
3

Description

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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the SVG reproduction in the issue and inspect convert_offset and the TODO in resolve_primitive_region about rotation and skew. Compare the renderer's output with the supplied resvg and Chrome examples for the listed rotations. Done means determining the correct transform and rotation-center behavior and covering the resulting behavior with a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.