From d246df042ac8fb7e0d8768af5e80786905be2c7e Mon Sep 17 00:00:00 2001 From: azagaya Date: Sat, 30 Nov 2019 09:26:58 -0300 Subject: [PATCH] Another attemt to workarround flood_fill bug --- Scripts/Canvas.gd | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Scripts/Canvas.gd b/Scripts/Canvas.gd index 4c340155a..3f9c461a0 100644 --- a/Scripts/Canvas.gd +++ b/Scripts/Canvas.gd @@ -626,9 +626,7 @@ 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: + if target_color == replace_color: break var west : Vector2 = n var east : Vector2 = n @@ -640,6 +638,7 @@ func flood_fill(pos : Vector2, target_color : Color, replace_color : Color) -> v var p := Vector2(px, n.y) #Draw layers[current_layer_index][0].set_pixelv(p, replace_color) + replace_color = layers[current_layer_index][0].get_pixelv(p) var north := p + Vector2.UP var south := p + Vector2.DOWN if north.y >= north_limit && layers[current_layer_index][0].get_pixelv(north) == target_color: