Normalize dimensions (#527)

* normalize dimensions of non-linear elements

* fix element type check regression
This commit is contained in:
David Luzar 2020-01-24 20:45:52 +01:00 committed by GitHub
parent d65e90209c
commit afb1d6725f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 141 additions and 39 deletions

View file

@ -2,6 +2,7 @@ import rough from "roughjs/bin/rough";
import { ExcalidrawElement } from "../element/types";
import { getElementAbsoluteCoords } from "../element/bounds";
import { renderScene } from "../renderer/renderScene";
import { distance } from "../utils";
export function getExportCanvasPreview(
elements: readonly ExcalidrawElement[],
@ -40,10 +41,6 @@ export function getExportCanvasPreview(
subCanvasY2 = Math.max(subCanvasY2, y2);
});
function distance(x: number, y: number) {
return Math.abs(x > y ? x - y : y - x);
}
const width = distance(subCanvasX1, subCanvasX2) + exportPadding * 2;
const height = distance(subCanvasY1, subCanvasY2) + exportPadding * 2;
const tempCanvas: any = createCanvas(width, height);