From a0aa2612e17e0d7342ca6a10daeed487d2b19924 Mon Sep 17 00:00:00 2001 From: Zhilin Liu Date: Mon, 19 Feb 2024 17:09:30 +0800 Subject: [PATCH] fix: canvas size with zoom (#92) --- src/BlockHub/CanvasBlock/Canvas.vue | 2 +- src/Kernel/ToolBox/controller/PenToolController.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/BlockHub/CanvasBlock/Canvas.vue b/src/BlockHub/CanvasBlock/Canvas.vue index f4414bd..3e067ac 100644 --- a/src/BlockHub/CanvasBlock/Canvas.vue +++ b/src/BlockHub/CanvasBlock/Canvas.vue @@ -34,7 +34,7 @@ const render = () => { } context.save() context.strokeStyle = 'black' - context.lineWidth = 1 + context.lineWidth = 2 context.beginPath() const start = points.get(0) as OriginMap context.moveTo(start.x as number, start.y as number) diff --git a/src/Kernel/ToolBox/controller/PenToolController.ts b/src/Kernel/ToolBox/controller/PenToolController.ts index 7378da0..2ee75bc 100644 --- a/src/Kernel/ToolBox/controller/PenToolController.ts +++ b/src/Kernel/ToolBox/controller/PenToolController.ts @@ -1,7 +1,7 @@ import { toSlideCoords } from '@Utils/toSlideCoords' import { ToolController } from './_ToolController' import { CanvasBlock } from '@BlockHub/CanvasBlock/CanvasBlock' -import { selectionManager, slideManager, toolBox } from '@Kernel/index' +import { selectionManager, slideManager, toolBox, zoom } from '@Kernel/index' import { ArrayStore } from '@Kernel/Store/ArrayStore' import { OriginMap } from '@Kernel/Store/_Store' @@ -16,7 +16,7 @@ export class PenToolController extends ToolController { this._drawing = true const slideElement = event.currentTarget as HTMLElement const slideRect = slideElement.getBoundingClientRect() - this._canvasBlock = new CanvasBlock(0, 0, slideRect.width, slideRect.height) + this._canvasBlock = new CanvasBlock(0, 0, slideRect.width / zoom.value, slideRect.height / zoom.value) slideManager.currentSlide.addBlock(this._canvasBlock) }