From db29c1af67f150e9dfb0f7fb807a3829777baa44 Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Tue, 7 Jan 2020 17:20:25 +0200 Subject: [PATCH] Fixed crash that occured when trying to delete contents of a selection that were outside the canvas' borders --- Scripts/Canvas.gd | 4 ++-- Scripts/SelectionRectangle.gd | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Scripts/Canvas.gd b/Scripts/Canvas.gd index d622f6a1b..767e46f6d 100644 --- a/Scripts/Canvas.gd +++ b/Scripts/Canvas.gd @@ -95,7 +95,7 @@ func _input(event : InputEvent) -> void: update() sprite_changed_this_frame = false - current_pixel = get_local_mouse_position() - location + current_pixel = get_local_mouse_position() + location var mouse_pos := current_pixel var mouse_pos_floored := mouse_pos.floor() var mouse_pos_ceiled := mouse_pos.ceil() @@ -449,7 +449,7 @@ func _draw() -> void: draw_line(Vector2(location.x, y), Vector2(size.x, y), Global.grid_color, true) #Draw rectangle to indicate the pixel currently being hovered on - var mouse_pos := get_local_mouse_position() + location + var mouse_pos := current_pixel if point_in_rectangle(mouse_pos, location, location + size): mouse_pos = mouse_pos.floor() if Global.left_square_indicator_visible && Global.can_draw: diff --git a/Scripts/SelectionRectangle.gd b/Scripts/SelectionRectangle.gd index ef7a54057..63dff97cf 100644 --- a/Scripts/SelectionRectangle.gd +++ b/Scripts/SelectionRectangle.gd @@ -133,7 +133,8 @@ func _process(delta : float) -> void: Global.canvas.handle_undo("Draw") for xx in range(start_pos.x, end_pos.x): for yy in range(start_pos.y, end_pos.y): - layer.set_pixel(xx, yy, Color(0, 0, 0, 0)) + if point_in_rectangle(Vector2(xx, yy), Global.canvas.location - Vector2.ONE, Global.canvas.location + Global.canvas.size): + layer.set_pixel(xx, yy, Color(0, 0, 0, 0)) Global.canvas.handle_redo("Draw")