Skip to content

Commit

Permalink
Fix intersections
Browse files Browse the repository at this point in the history
  • Loading branch information
OverloadedOrama committed Jun 26, 2022
1 parent c34a98a commit 26cb931
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/Tools/SelectionTools/ColorSelect.gd
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ func apply_selection(position: Vector2) -> void:
var pos := Vector2(x, y)
if color.is_equal_approx(cel_image.get_pixelv(pos)):
if _intersect:
selection_map_copy.select_pixel(pos, selection_map_copy.is_pixel_selected(pos))
var selected: bool = project.selection_map.is_pixel_selected(pos)
selection_map_copy.select_pixel(pos, selected)
else:
selection_map_copy.select_pixel(pos, !_subtract)

Expand Down
3 changes: 2 additions & 1 deletion src/Tools/SelectionTools/EllipseSelect.gd
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func apply_selection(_position: Vector2) -> void:


func set_ellipse(selection_map: SelectionMap, position: Vector2) -> void:
var project: Project = Global.current_project
var bitmap_size: Vector2 = selection_map.get_size()
if _intersect:
selection_map.clear()
Expand All @@ -120,7 +121,7 @@ func set_ellipse(selection_map: SelectionMap, position: Vector2) -> void:
if pos.x < 0 or pos.y < 0 or pos.x >= bitmap_size.x or pos.y >= bitmap_size.y:
continue
if _intersect:
if selection_map.is_pixel_selected(pos):
if project.selection_map.is_pixel_selected(pos):
selection_map.select_pixel(pos, true)
else:
selection_map.select_pixel(pos, !_subtract)
Expand Down
4 changes: 2 additions & 2 deletions src/Tools/SelectionTools/Lasso.gd
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func lasso_selection(selection_map: SelectionMap, points: PoolVector2Array) -> v
if point.x < 0 or point.y < 0 or point.x >= size.x or point.y >= size.y:
continue
if _intersect:
if selection_map.is_pixel_selected(point):
if project.selection_map.is_pixel_selected(point):
selection_map.select_pixel(point, true)
else:
selection_map.select_pixel(point, !_subtract)
Expand All @@ -122,7 +122,7 @@ func lasso_selection(selection_map: SelectionMap, points: PoolVector2Array) -> v
v.y = y
if Geometry.is_point_in_polygon(v, points):
if _intersect:
if selection_map.is_pixel_selected(v):
if project.selection_map.is_pixel_selected(v):
selection_map.select_pixel(v, true)
else:
selection_map.select_pixel(v, !_subtract)
Expand Down
3 changes: 2 additions & 1 deletion src/Tools/SelectionTools/MagicWand.gd
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ func _select_segments(selection_map: SelectionMap) -> void:


func _set_bit(p: Vector2, selection_map: SelectionMap) -> void:
var project: Project = Global.current_project
if _intersect:
selection_map.select_pixel(p, selection_map.is_pixel_selected(p))
selection_map.select_pixel(p, project.selection_map.is_pixel_selected(p))
else:
selection_map.select_pixel(p, !_subtract)

0 comments on commit 26cb931

Please sign in to comment.