fixed up, test works and passes

This commit is contained in:
Nate Diamond 2017-06-28 00:11:00 -04:00
parent da3248c18c
commit 670faf0c82
2 changed files with 4 additions and 4 deletions

View File

@ -336,7 +336,7 @@ def floodfill(image, xy, value, border=None, thresh=0):
x, y = xy x, y = xy
try: try:
background = pixel[x, y] background = pixel[x, y]
if background == value: if _color_diff(value, background) <= thresh:
return # seed point already has fill color return # seed point already has fill color
pixel[x, y] = value pixel[x, y] = value
except (ValueError, IndexError): except (ValueError, IndexError):

View File

@ -409,15 +409,15 @@ class TestImageDraw(PillowTestCase):
# Arrange # Arrange
im = Image.new("RGB", (W, H)) im = Image.new("RGB", (W, H))
draw = ImageDraw.Draw(im) draw = ImageDraw.Draw(im)
draw.rectangle(BBOX2, outline="yellow", fill="green") draw.rectangle(BBOX2, outline="darkgreen", fill="green")
centre_point = (int(W/2), int(H/2)) centre_point = (int(W/2), int(H/2))
# Act # Act
ImageDraw.floodfill( ImageDraw.floodfill(
im, centre_point, ImageColor.getrgb("red"), im, centre_point, ImageColor.getrgb("red"),
thresh=100) thresh=30)
del draw del draw
im.save("x.png")
# Assert # Assert
self.assert_image_equal( self.assert_image_equal(
im, Image.open("Tests/images/imagedraw_floodfill2.png")) im, Image.open("Tests/images/imagedraw_floodfill2.png"))