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
|
||||
try:
|
||||
background = pixel[x, y]
|
||||
if background == value:
|
||||
if _color_diff(value, background) <= thresh:
|
||||
return # seed point already has fill color
|
||||
pixel[x, y] = value
|
||||
except (ValueError, IndexError):
|
||||
|
|
|
@ -409,15 +409,15 @@ class TestImageDraw(PillowTestCase):
|
|||
# Arrange
|
||||
im = Image.new("RGB", (W, H))
|
||||
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))
|
||||
|
||||
# Act
|
||||
ImageDraw.floodfill(
|
||||
im, centre_point, ImageColor.getrgb("red"),
|
||||
thresh=100)
|
||||
thresh=30)
|
||||
del draw
|
||||
|
||||
im.save("x.png")
|
||||
# Assert
|
||||
self.assert_image_equal(
|
||||
im, Image.open("Tests/images/imagedraw_floodfill2.png"))
|
||||
|
|
Loading…
Reference in New Issue
Block a user