Skip to content

Commit 007b964

Browse files
author
Daniele Tolomelli
committed
Drawing a square when pressing Shift using the Rectangle tool
1 parent 5cbb73d commit 007b964

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lorien/InfiniteCanvas/Tools/RectangleTool.gd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ func _make_rectangle(pressure: float) -> void:
3636
pressure = pressure_curve.sample(pressure)
3737

3838
var bottom_right_point := _cursor.global_position
39+
# draw a square if Shift is pressed
40+
if Input.is_key_pressed(KEY_SHIFT):
41+
var drag_dir := _cursor.global_position - _start_position_top_left
42+
bottom_right_point = _start_position_top_left + drag_dir.project(sign(drag_dir))
3943
var height := bottom_right_point.y - _start_position_top_left.y
4044
var width := bottom_right_point.x - _start_position_top_left.x
4145
var top_right_point := _start_position_top_left + Vector2(width, 0)

0 commit comments

Comments
 (0)