From 95129beaec5626cb0caee447c5888776247e28d4 Mon Sep 17 00:00:00 2001 From: wuchenguang1998 <63847336+wuchenguang1998@users.noreply.github.com> Date: Thu, 16 May 2024 22:01:04 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E8=BE=85=E5=8A=A9?= =?UTF-8?q?=E7=BA=BF=E7=BB=98=E5=88=B6=20(#386)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/plugin/AlignGuidLinePlugin.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/core/plugin/AlignGuidLinePlugin.ts b/packages/core/plugin/AlignGuidLinePlugin.ts index 43f06db6..143626e3 100644 --- a/packages/core/plugin/AlignGuidLinePlugin.ts +++ b/packages/core/plugin/AlignGuidLinePlugin.ts @@ -71,14 +71,8 @@ class AlignGuidLinePlugin { function drawLine(x1: number, y1: number, x2: number, y2: number) { if (viewportTransform == null) return; - ctx.save(); - ctx.lineWidth = This.defautOption.width; - ctx.strokeStyle = This.defautOption.color; - ctx.beginPath(); ctx.moveTo(x1 * zoom + viewportTransform[4], y1 * zoom + viewportTransform[5]); ctx.lineTo(x2 * zoom + viewportTransform[4], y2 * zoom + viewportTransform[5]); - ctx.stroke(); - ctx.restore(); } function isInRange(value1: number, value2: number) { @@ -294,12 +288,18 @@ class AlignGuidLinePlugin { }); canvas.on('after:render', () => { + ctx.save(); + ctx.beginPath(); + ctx.lineWidth = This.defautOption.width; + ctx.strokeStyle = This.defautOption.color; for (let i = verticalLines.length; i--; ) { drawVerticalLine(verticalLines[i]); } for (let j = horizontalLines.length; j--; ) { drawHorizontalLine(horizontalLines[j]); } + ctx.stroke(); + ctx.restore(); // noinspection NestedAssignmentJS verticalLines.length = 0;