mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-28 08:04:45 +03:00
fixed up, test works and passes
This commit is contained in:
parent
da3248c18c
commit
670faf0c82
|
@ -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):
|
||||||
|
|
|
@ -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"))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user