From 47d415e31ca2e0e65a7a5a428cde996678fe7dfd Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Wed, 17 Jul 2024 14:33:58 +1000 Subject: [PATCH] tidy(ui): CanvasEraserLine --- .../controlLayers/konva/CanvasEraserLine.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/invokeai/frontend/web/src/features/controlLayers/konva/CanvasEraserLine.ts b/invokeai/frontend/web/src/features/controlLayers/konva/CanvasEraserLine.ts index b10b9d64fd..f1d93fe9a9 100644 --- a/invokeai/frontend/web/src/features/controlLayers/konva/CanvasEraserLine.ts +++ b/invokeai/frontend/web/src/features/controlLayers/konva/CanvasEraserLine.ts @@ -8,15 +8,16 @@ export class CanvasEraserLine { static GROUP_NAME = `${CanvasEraserLine.NAME_PREFIX}_group`; static LINE_NAME = `${CanvasEraserLine.NAME_PREFIX}_line`; + private state: EraserLine; + id: string; konva: { group: Konva.Group; line: Konva.Line; }; - lastEraserLine: EraserLine; - constructor(eraserLine: EraserLine) { - const { id, strokeWidth, clip, points } = eraserLine; + constructor(state: EraserLine) { + const { id, strokeWidth, clip, points } = state; this.id = id; this.konva = { group: new Konva.Group({ @@ -40,19 +41,19 @@ export class CanvasEraserLine { }), }; this.konva.group.add(this.konva.line); - this.lastEraserLine = eraserLine; + this.state = state; } - update(eraserLine: EraserLine, force?: boolean): boolean { - if (this.lastEraserLine !== eraserLine || force) { - const { points, clip, strokeWidth } = eraserLine; + update(state: EraserLine, force?: boolean): boolean { + if (this.state !== state || force) { + const { points, clip, strokeWidth } = state; this.konva.line.setAttrs({ // A line with only one point will not be rendered, so we duplicate the points to make it visible points: points.length === 2 ? [...points, ...points] : points, clip, strokeWidth, }); - this.lastEraserLine = eraserLine; + this.state = state; return true; } else { return false;