From 5a5fd64176de288c7d0e02ab4cbbc2607dc3df20 Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Sun, 28 Apr 2024 20:12:06 +0800 Subject: [PATCH] fix: checkbox custom size rendering error #529 --- src/editor/core/draw/particle/CheckboxParticle.ts | 9 ++++----- src/editor/core/draw/particle/ListParticle.ts | 5 ++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/editor/core/draw/particle/CheckboxParticle.ts b/src/editor/core/draw/particle/CheckboxParticle.ts index d453038..b16e9a3 100644 --- a/src/editor/core/draw/particle/CheckboxParticle.ts +++ b/src/editor/core/draw/particle/CheckboxParticle.ts @@ -61,11 +61,10 @@ export class CheckboxParticle { // 勾选对号 ctx.beginPath() ctx.strokeStyle = fontStyle - ctx.lineWidth = lineWidth * 2 - ctx.moveTo(left + 2 * scale, top + 7 * scale) - ctx.lineTo(left + 7 * scale, top + 11 * scale) - ctx.moveTo(left + 6.5 * scale, top + 11 * scale) - ctx.lineTo(left + 12 * scale, top + 3 * scale) + ctx.lineWidth = lineWidth * 2 * scale + ctx.moveTo(left + 2 * scale, top + height / 2) + ctx.lineTo(left + width / 2, top + height - 3 * scale) + ctx.lineTo(left + width - 2 * scale, top + 3 * scale) ctx.stroke() } else { ctx.lineWidth = lineWidth diff --git a/src/editor/core/draw/particle/ListParticle.ts b/src/editor/core/draw/particle/ListParticle.ts index 1405683..1548979 100644 --- a/src/editor/core/draw/particle/ListParticle.ts +++ b/src/editor/core/draw/particle/ListParticle.ts @@ -133,13 +133,16 @@ export class ListParticle { ctx: CanvasRenderingContext2D, listElementList: IElement[] ): number { - const { scale } = this.options + const { scale, checkbox } = this.options const startElement = listElementList[0] // 非递增样式返回固定值 if ( startElement.listStyle && startElement.listStyle !== ListStyle.DECIMAL ) { + if (startElement.listStyle === ListStyle.CHECKBOX) { + return (checkbox.width + this.LIST_GAP) * scale + } return this.UN_COUNT_STYLE_WIDTH * scale } // 计算列表数量