From f083be93914e2ee09d091fd2a2e86930a5e5dff9 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Sun, 16 Jun 2024 20:29:37 +1000 Subject: [PATCH] feat(ui): hold shift w/ brush to draw straight line --- .../features/controlLayers/konva/events.ts | 78 ++++++++++++------- 1 file changed, 51 insertions(+), 27 deletions(-) diff --git a/invokeai/frontend/web/src/features/controlLayers/konva/events.ts b/invokeai/frontend/web/src/features/controlLayers/konva/events.ts index f275bf415f..1d98db35ec 100644 --- a/invokeai/frontend/web/src/features/controlLayers/konva/events.ts +++ b/invokeai/frontend/web/src/features/controlLayers/konva/events.ts @@ -187,36 +187,60 @@ export const setStageEventHandlers = ({ setLastMouseDownPos(pos); if (toolState.selected === 'brush') { - onBrushLineAdded( - { - id: selectedEntity.id, - points: [ - pos.x - selectedEntity.x, - pos.y - selectedEntity.y, - pos.x - selectedEntity.x, - pos.y - selectedEntity.y, - ], - color: getCurrentFill(), - width: toolState.brush.width, - }, - selectedEntity.type - ); + if (e.evt.shiftKey) { + // Extend the last line straight to the new point + setLastAddedPoint(pos); + onPointAddedToLine( + { + id: selectedEntity.id, + point: [pos.x - selectedEntity.x, pos.y - selectedEntity.y], + }, + selectedEntity.type + ); + } else { + onBrushLineAdded( + { + id: selectedEntity.id, + points: [ + pos.x - selectedEntity.x, + pos.y - selectedEntity.y, + pos.x - selectedEntity.x, + pos.y - selectedEntity.y, + ], + color: getCurrentFill(), + width: toolState.brush.width, + }, + selectedEntity.type + ); + } } if (toolState.selected === 'eraser') { - onEraserLineAdded( - { - id: selectedEntity.id, - points: [ - pos.x - selectedEntity.x, - pos.y - selectedEntity.y, - pos.x - selectedEntity.x, - pos.y - selectedEntity.y, - ], - width: toolState.eraser.width, - }, - selectedEntity.type - ); + if (e.evt.shiftKey) { + // Extend the last line straight to the new point + setLastAddedPoint(pos); + onPointAddedToLine( + { + id: selectedEntity.id, + point: [pos.x - selectedEntity.x, pos.y - selectedEntity.y], + }, + selectedEntity.type + ); + } else { + onEraserLineAdded( + { + id: selectedEntity.id, + points: [ + pos.x - selectedEntity.x, + pos.y - selectedEntity.y, + pos.x - selectedEntity.x, + pos.y - selectedEntity.y, + ], + width: toolState.eraser.width, + }, + selectedEntity.type + ); + } } });