From f10bf4c96f734c15e5ffb1d4f1d35819348eb176 Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Sat, 30 Nov 2019 03:22:56 +0200 Subject: [PATCH] Possible fix of #10 - thanks azagaya! --- Main.tscn | 1 + Scripts/Canvas.gd | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Main.tscn b/Main.tscn index d0d373409..c8e89b33a 100644 --- a/Main.tscn +++ b/Main.tscn @@ -476,6 +476,7 @@ hint_tooltip = "Color picker for the right tool" mouse_default_cursor_shape = 2 size_flags_horizontal = 0 size_flags_vertical = 0 +color = Color( 1, 1, 1, 1 ) [node name="BrushType" type="HBoxContainer" parent="MenuAndUI/UI/ToolPanel/Tools/ToolOptions/RightToolOptions"] margin_top = 82.0 diff --git a/Scripts/Canvas.gd b/Scripts/Canvas.gd index 2d1482c47..4c340155a 100644 --- a/Scripts/Canvas.gd +++ b/Scripts/Canvas.gd @@ -625,6 +625,11 @@ func flood_fill(pos : Vector2, target_color : Color, replace_color : Color) -> v var q = [pos] for n in q: + #If the difference in colors is very small, break the loop (thanks @azagaya on GitHub!) + var c = target_color - replace_color + var dist = sqrt(c.r*c.r + c.g*c.g + c.b*c.b + c.a*c.a) + if dist <= 0.005: + break var west : Vector2 = n var east : Vector2 = n while west.x >= west_limit && layers[current_layer_index][0].get_pixelv(west) == target_color: