Skip to content

Support patternContentUnits=objectBoundingBox for pattern fills#120

Open
rursache wants to merge 1 commit intoswhitty:mainfrom
rursache:fix/52-base64-image-in-pattern
Open

Support patternContentUnits=objectBoundingBox for pattern fills#120
rursache wants to merge 1 commit intoswhitty:mainfrom
rursache:fix/52-base64-image-in-pattern

Conversation

@rursache
Copy link

Summary

  • Implement patternContentUnits="objectBoundingBox" support for pattern fills
  • When this attribute is set, pattern coordinates are in [0,1] range relative to the filled element's bounding box
  • The pattern frame is now scaled to the shape's bounding box at render time
  • Also fixes a bug in firstGraphicsElement(with:) where the search would stop prematurely at the first container element, even if the target element was a later sibling

Test plan

  • Added testDOMPatternObjectBoundingBox() verifying objectBoundingBox patterns preserve content units
  • Added testDOMPatternUserSpaceOnUse() verifying default patterns use userSpaceOnUse
  • Added firstGraphicsElementSearchesPastContainers() verifying element lookup doesn't stop at containers
  • All 196 tests pass

Closes #52

When a pattern uses patternContentUnits="objectBoundingBox", scale
the pattern frame to the bounding box of the filled element. This
fixes rendering of patterns that reference images via <use> elements
in <defs>, where the pattern coordinates are in [0,1] range.

Also fixes a bug in firstGraphicsElement(with:) where the search
would stop prematurely at the first container element, even if the
target element was a later sibling.

Closes swhitty#52
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

Successfully merging this pull request may close these issues.

Embedded Base64 image isn’t rendered

1 participant