From 39a4f42e3d673d9bcc4b322cf907d8672c8cb4f7 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Wed, 14 Nov 2018 15:47:26 +0100 Subject: [PATCH] Resize canvas to handle rotation --- src/ol/renderer/canvas/IntermediateCanvas.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ol/renderer/canvas/IntermediateCanvas.js b/src/ol/renderer/canvas/IntermediateCanvas.js index 27e325f132..fe4c4ddc98 100644 --- a/src/ol/renderer/canvas/IntermediateCanvas.js +++ b/src/ol/renderer/canvas/IntermediateCanvas.js @@ -127,8 +127,14 @@ class IntermediateCanvasRenderer extends CanvasLayerRenderer { clear(frameState) { const pixelRatio = frameState.pixelRatio; const canvas = this.layerContext.canvas; - const width = Math.round(frameState.size[0] * pixelRatio); - const height = Math.round(frameState.size[1] * pixelRatio); + + let width = Math.round(frameState.size[0] * pixelRatio); + let height = Math.round(frameState.size[1] * pixelRatio); + const rotation = frameState.viewState.rotation; + if (rotation) { + const size = Math.round(Math.sqrt(width * width + height * height)); + width = height = size; + } if (canvas.width != width || canvas.height != height) { canvas.width = width;