Skip to content

Commit

Permalink
Fixed crash that occured when trying to delete contents of a selectio…
Browse files Browse the repository at this point in the history
…n that were outside the canvas' borders
  • Loading branch information
OverloadedOrama committed Jan 7, 2020
1 parent ff3b5e3 commit db29c1a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Scripts/Canvas.gd
Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion Scripts/SelectionRectangle.gd
Expand Up @@ -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")


Expand Down

0 comments on commit db29c1a

Please sign in to comment.