mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 17:55:37 +02:00
Use the Util.getAxialAlignedBoundingBox
helper function more
There's a couple of spots in the code-base that effectively re-implement this helper function, which seems like unnecessary repetition.
This commit is contained in:
parent
071e6bc7e7
commit
d3c0928121
3 changed files with 14 additions and 27 deletions
|
@ -2439,19 +2439,11 @@ class CanvasGraphics {
|
|||
|
||||
const inv = getCurrentTransformInverse(ctx);
|
||||
if (inv) {
|
||||
const canvas = ctx.canvas;
|
||||
const width = canvas.width;
|
||||
const height = canvas.height;
|
||||
|
||||
const bl = Util.applyTransform([0, 0], inv);
|
||||
const br = Util.applyTransform([0, height], inv);
|
||||
const ul = Util.applyTransform([width, 0], inv);
|
||||
const ur = Util.applyTransform([width, height], inv);
|
||||
|
||||
const x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
|
||||
const y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
|
||||
const x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
|
||||
const y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
|
||||
const { width, height } = ctx.canvas;
|
||||
const [x0, y0, x1, y1] = Util.getAxialAlignedBoundingBox(
|
||||
[0, 0, width, height],
|
||||
inv
|
||||
);
|
||||
|
||||
this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue