Smaller canvas when rotating vector layers
This commit is contained in:
@@ -700,8 +700,8 @@ class CanvasExecutor {
|
||||
backgroundFill = backgroundStroke = false;
|
||||
}
|
||||
|
||||
if (!rotateWithView) {
|
||||
rotation -= viewRotation;
|
||||
if (rotateWithView) {
|
||||
rotation += viewRotation;
|
||||
}
|
||||
let widthIndex = 0;
|
||||
for (; d < dd; d += 2) {
|
||||
|
||||
@@ -192,7 +192,7 @@ class CanvasLayerRenderer extends LayerRenderer {
|
||||
const sy = -sx;
|
||||
const dx2 = -viewState.center[0] + offsetX;
|
||||
const dy2 = -viewState.center[1];
|
||||
return composeTransform(this.transform_, dx1, dy1, sx, sy, 0, dx2, dy2);
|
||||
return composeTransform(this.transform_, dx1, dy1, sx, sy, -viewState.rotation, dx2, dy2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -378,12 +378,8 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
|
||||
|
||||
// resize and clear
|
||||
const canvas = context.canvas;
|
||||
let width = Math.round(size[0] * pixelRatio);
|
||||
let height = Math.round(size[1] * pixelRatio);
|
||||
if (rotation) {
|
||||
const size = Math.round(Math.sqrt(width * width + height * height));
|
||||
width = height = size;
|
||||
}
|
||||
const width = Math.round(size[0] * pixelRatio);
|
||||
const height = Math.round(size[1] * pixelRatio);
|
||||
if (canvas.width != width || canvas.height != height) {
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
@@ -462,11 +458,6 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
|
||||
canvas.style.opacity = opacity;
|
||||
}
|
||||
|
||||
const canvasTransform = 'rotate(' + rotation + 'rad)';
|
||||
if (canvasTransform !== canvas.style.transform) {
|
||||
canvas.style.transform = canvasTransform;
|
||||
}
|
||||
|
||||
return this.container_;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user