From 8a91ca4e4cce46b2c86ee56b402c565116870f70 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Fri, 7 Oct 2022 16:46:23 -0400 Subject: [PATCH] fix: Fix an issue cropping large canvas quads --- src/canvas/quadFeature.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/canvas/quadFeature.js b/src/canvas/quadFeature.js index dad410440a..d836bce744 100644 --- a/src/canvas/quadFeature.js +++ b/src/canvas/quadFeature.js @@ -172,8 +172,10 @@ var canvas_quadFeature = function (arg) { var p0 = map.gcsToDisplay({x: quad.pos[0], y: quad.pos[1]}, null), p2 = map.gcsToDisplay({x: quad.pos[6], y: quad.pos[7]}, null), p3 = map.gcsToDisplay({x: quad.pos[9], y: quad.pos[10]}, null); - context2d.setTransform((p3.x - p2.x) / w, (p3.y - p2.y) / w, - (p0.x - p2.x) / h, (p0.y - p2.y) / h, + const cw = Math.min(w, quad.crop ? quad.crop.x || w : w); + const ch = Math.min(h, quad.crop ? quad.crop.y || h : h); + context2d.setTransform((p3.x - p2.x) / cw, (p3.y - p2.y) / cw, + (p0.x - p2.x) / ch, (p0.y - p2.y) / ch, p2.x, p2.y); if (quad.opacity !== opacity) { opacity = quad.opacity;