From 5985d4069aa08a32729f6e01e8641d577cad06e8 Mon Sep 17 00:00:00 2001 From: Rob Wu Date: Mon, 25 Mar 2019 01:03:26 +0100 Subject: [PATCH] TilingPattern: Add comment to explain the implementation --- src/display/pattern_helper.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/display/pattern_helper.js b/src/display/pattern_helper.js index a09aa6738..423deebd7 100644 --- a/src/display/pattern_helper.js +++ b/src/display/pattern_helper.js @@ -330,6 +330,26 @@ var TilingPattern = (function TilingPatternClosure() { info('TilingType: ' + tilingType); + // A tiling pattern as defined by PDF spec 8.7.2 is a cell whose size is + // described by bbox, and may repeat regularly by shifting the cell by + // xstep and ystep. + // Because the HTML5 canvas API does not support pattern repetition with + // gaps in between, we use the xstep/ystep instead of the bbox's size. + // + // This has the following consequences (similarly for ystep): + // + // - If xstep is the same as bbox, then there is no observable difference. + // + // - If xstep is larger than bbox, then the pattern canvas is partially + // empty: the area bounded by bbox is painted, the outside area is void. + // + // - If xstep is smaller than bbox, then the pixels between xstep and the + // bbox boundary will be missing. This is INCORRECT behavior. + // "Figures on adjacent tiles should not overlap" (PDF spec 8.7.3.1), + // but overlapping cells without common pixels are still valid. + // TODO: Fix the implementation, to allow this scenario to be painted + // correctly. + var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3]; // Obtain scale from matrix and current transformation matrix.