Fix the fill area computation for a rotated tiling pattern

Only two diagonal corners of the fill area were transformed into pattern
space, so with a rotated pattern matrix the area could wrongly look like it
fits within a single tile.

It fixes #21878.
This commit is contained in:
Calixte Denizet
2026-09-03 15:52:48 +02:00
parent 74515c623c
commit 7071056e95
4 changed files with 19 additions and 9 deletions
+11 -9
View File
@@ -596,15 +596,17 @@ class TilingPattern {
// Converts clippedBBox from device space to pattern space and stores it
// as [width, height, offsetX, offsetY] in dims.
updatePatternDims(clippedBBox, dims) {
const inv = Util.inverseTransform(this.patternBaseMatrix);
const c1 = [clippedBBox[0], clippedBBox[1]];
const c2 = [clippedBBox[2], clippedBBox[3]];
Util.applyTransform(c1, inv);
Util.applyTransform(c2, inv);
dims[0] = Math.abs(c2[0] - c1[0]);
dims[1] = Math.abs(c2[1] - c1[1]);
dims[2] = Math.min(c1[0], c2[0]);
dims[3] = Math.min(c1[1], c2[1]);
// Two diagonal corners aren't enough when the pattern matrix is rotated.
const bbox = [Infinity, Infinity, -Infinity, -Infinity];
Util.axialAlignedBoundingBox(
clippedBBox,
Util.inverseTransform(this.patternBaseMatrix),
bbox
);
dims[0] = bbox[2] - bbox[0];
dims[1] = bbox[3] - bbox[1];
dims[2] = bbox[0];
dims[3] = bbox[1];
}
// Renders the tile operators onto a fresh canvas and returns it.
+1
View File
@@ -954,3 +954,4 @@
!bug1898053_minimal.pdf
!bug2055455.pdf
!issue20294_reduced.pdf
!issue21878.pdf
Binary file not shown.
+7
View File
@@ -14540,5 +14540,12 @@
"md5": "29bdb56f4249dc642556c36ecb8de22b",
"rounds": 1,
"type": "eq"
},
{
"id": "issue21878",
"file": "pdfs/issue21878.pdf",
"md5": "0ab77bc45682d06b55499b95b42f907d",
"rounds": 1,
"type": "eq"
}
]