Remove last get/setTransform (#964)

My original hack to put the scale when we create the canvas element doesn't make much sense. It should be done when we are rendering the scene. I moved it there in this PR.

The rest was all about forwarding the scale to where it's needed.
This commit is contained in:
Christopher Chedeau 2020-03-15 12:25:18 -07:00 committed by GitHub
parent 79ea76b48b
commit 2937efacde
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 13 deletions

View file

@ -36,7 +36,6 @@ export function exportToCanvas(
const height = distance(minY, maxY) + exportPadding * 2;
const tempCanvas: any = createCanvas(width, height);
tempCanvas.getContext("2d")?.scale(scale, scale);
renderScene(
elements,

View file

@ -1,4 +1,4 @@
export function getZoomOrigin(canvas: HTMLCanvasElement | null) {
export function getZoomOrigin(canvas: HTMLCanvasElement | null, scale: number) {
if (canvas === null) {
return { x: 0, y: 0 };
}
@ -7,8 +7,8 @@ export function getZoomOrigin(canvas: HTMLCanvasElement | null) {
return { x: 0, y: 0 };
}
const normalizedCanvasWidth = canvas.width / context.getTransform().a;
const normalizedCanvasHeight = canvas.height / context.getTransform().d;
const normalizedCanvasWidth = canvas.width / scale;
const normalizedCanvasHeight = canvas.height / scale;
return {
x: normalizedCanvasWidth / 2,