Skip to content

patternTransform browser implementations do not match spec #293

@AmeliaBR

Description

@AmeliaBR

The definition of the SVG patternTransform attribute says (SVG 1.1)(SVG 2):

Contains the definition of an optional additional transformation from the pattern coordinate system onto the target coordinate system (i.e., 'userSpaceOnUse' or 'objectBoundingBox'). This allows for things such as skewing the pattern tiles. This additional transformation matrix is post-multiplied to (i.e., inserted to the right of) any previously defined transformations, including the implicit transformation necessary to convert from object bounding box units to local coordinate system.

In other words, when using objectBoundingBox units, a translation of 0.5,0.5 should shift the pattern tile by half the width and height of the box being painted. And a rotation around the point 0.5, 0.5 should be a rotation around the center of the box.

This is how it works with gradientTransform.

But none of the browsers apply it this way for patternTransform. Instead they always apply the transforms in user space coordinates. So a translation of 0.5,0.5 is just a shift of half a pixel in each direction.

But what's really weird is the rotate(45, 0.5,0.5) transform. It seems like it is rotating around the 0.5px,0.5px point of the user space coordinate system, not around the 0.5px,0.5px point of each tile or bounding box.

My guess is part of the problem is that there are two coordinate systems for patterns: the pattern tile (patternUnits) versus the pattern contents (patternContentUnits). So it's not really clear what should happen, according to spec, if the two unit types don't match each other, or if there is a viewBox on the pattern. I personally would expect the transform to apply to each composited pattern tile, in the units used to define the pattern tile dimensions. But that's not exactly spelled out in the spec.

But what I don't know is why no one ever brought up the issue with the spec so that it could get fixed.

So, something's gotta give. Either pave the erratic cowpath and spec what the browsers are doing (after first clearly figuring out what that is), or tighten up the definition and then file bugs on every browser. All of which is now made more complicated by the fact that patternTransform is supposed to also be affected by transform-origin and other CSS Transforms properties.

PS, Thanks to @yoksel for identifying this problem in her SVG Conundrum pen

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions