Skip to content

Commit

Permalink
Drawing a square when pressing Shift using the Rectangle tool (#316)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniele Tolomelli <[email protected]>
  • Loading branch information
DanX3 and Daniele Tolomelli authored Dec 1, 2024
1 parent ca48546 commit c3cfed2
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 c3cfed2

Please sign in to comment.