1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-30 23:19:49 +00:00

Merge pull request #31 from azagaya/master

Another attemt to workarround flood_fill bug
This commit is contained in:
Overloaded 2019-11-30 16:16:31 +02:00 committed by GitHub
commit 1623f9ccb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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: