mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Normalize dimensions (#527)
* normalize dimensions of non-linear elements * fix element type check regression
This commit is contained in:
parent
d65e90209c
commit
afb1d6725f
6 changed files with 141 additions and 39 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue