Smaller canvas when rotating vector layers

This commit is contained in:
Tim Schaub
2018-11-15 11:37:45 +01:00
parent 26de43de0c
commit f90efac131
4 changed files with 7 additions and 26 deletions

View File

@@ -123,12 +123,8 @@ class CanvasVectorLayerRenderer extends CanvasLayerRenderer {
}
// resize and clear
let width = Math.round(frameState.size[0] * pixelRatio);
let height = Math.round(frameState.size[1] * pixelRatio);
if (rotation) {
const size = Math.round(Math.sqrt(width * width + height * height));
width = height = size;
}
const width = Math.round(frameState.size[0] * pixelRatio);
const height = Math.round(frameState.size[1] * pixelRatio);
if (canvas.width != width || canvas.height != height) {
canvas.width = width;
canvas.height = height;
@@ -193,12 +189,6 @@ class CanvasVectorLayerRenderer extends CanvasLayerRenderer {
canvas.style.opacity = opacity;
}
const rotation = frameState.viewState.rotation;
const transform = 'rotate(' + rotation + 'rad)';
if (transform !== canvas.style.transform) {
canvas.style.transform = transform;
}
return canvas;
}