Skip to content

Percentages in <pattern>s are resolved using the wrong viewport #12

@Felerius

Description

@Felerius

Percentages in patterns should be relative to the viewport of the <svg> they are defined in. Right now they are interpreted as relative to the viewport of the referencing shape element.

This could either mean somehow saving the viewport of each <svg> element (but when parsing the <pattern> the <svg> element it is defined in might not have been parsed yet), parsing all patterns in an initial pass (to an intermediate format) and then reference them in a second pass parsing all shape elements.

To test this, use the following svg:

<svg width="100" height="100">
  <defs>
    <pattern id="a" x="0" y="0" width="50%" height="50%" patternUnits="userSpaceOnUse">
      <circle cx="25%" cy="25%" r="25%" stroke="none" fill="blue"/>
    </pattern>
  </defs>
  <rect x="0" y="0" width="50" height="50" stroke="none" fill="url(#a)"/>
  <svg x="50" y="50" width="50" height="50">
    <rect x="0" y="0" width="50" height="50" stroke="none" fill="url(#a)"/>
  </svg>
</svg>

It should show two circles of the same size, and not one big one and a cluster of four small ones.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions