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