mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Another attemt to workarround flood_fill bug
This commit is contained in:
parent
f10bf4c96f
commit
d246df042a
|
@ -626,9 +626,7 @@ func flood_fill(pos : Vector2, target_color : Color, replace_color : Color) -> v
|
||||||
var q = [pos]
|
var q = [pos]
|
||||||
for n in q:
|
for n in q:
|
||||||
#If the difference in colors is very small, break the loop (thanks @azagaya on GitHub!)
|
#If the difference in colors is very small, break the loop (thanks @azagaya on GitHub!)
|
||||||
var c = target_color - replace_color
|
if 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
|
break
|
||||||
var west : Vector2 = n
|
var west : Vector2 = n
|
||||||
var east : 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)
|
var p := Vector2(px, n.y)
|
||||||
#Draw
|
#Draw
|
||||||
layers[current_layer_index][0].set_pixelv(p, replace_color)
|
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 north := p + Vector2.UP
|
||||||
var south := p + Vector2.DOWN
|
var south := p + Vector2.DOWN
|
||||||
if north.y >= north_limit && layers[current_layer_index][0].get_pixelv(north) == target_color:
|
if north.y >= north_limit && layers[current_layer_index][0].get_pixelv(north) == target_color:
|
||||||
|
|
Loading…
Reference in a new issue