Skip to content

Commit

Permalink
Drawing a square when pressing Shift using the Rectangle tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniele Tolomelli committed Nov 27, 2024
1 parent 5cbb73d commit ef57f8c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lorien/InfiniteCanvas/Tools/RectangleTool.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ef57f8c

Please sign in to comment.