From c3cfed2ca51faf437f4fa999437a523acef810c7 Mon Sep 17 00:00:00 2001 From: DanX3 Date: Sun, 1 Dec 2024 12:03:28 +0100 Subject: [PATCH] Drawing a square when pressing Shift using the Rectangle tool (#316) Co-authored-by: Daniele Tolomelli --- lorien/InfiniteCanvas/Tools/RectangleTool.gd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lorien/InfiniteCanvas/Tools/RectangleTool.gd b/lorien/InfiniteCanvas/Tools/RectangleTool.gd index f518a13..71b4ada 100644 --- a/lorien/InfiniteCanvas/Tools/RectangleTool.gd +++ b/lorien/InfiniteCanvas/Tools/RectangleTool.gd @@ -36,6 +36,10 @@ func _make_rectangle(pressure: float) -> void: pressure = pressure_curve.sample(pressure) var bottom_right_point := _cursor.global_position + # draw a square if Shift is pressed + if Input.is_key_pressed(KEY_SHIFT): + var drag_dir := _cursor.global_position - _start_position_top_left + bottom_right_point = _start_position_top_left + drag_dir.project(sign(drag_dir)) var height := bottom_right_point.y - _start_position_top_left.y var width := bottom_right_point.x - _start_position_top_left.x var top_right_point := _start_position_top_left + Vector2(width, 0)