Resize canvas to handle rotation

This commit is contained in:
Tim Schaub
2018-11-14 15:47:26 +01:00
parent 6234b69512
commit 39a4f42e3d

View File

@@ -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;