Merge pull request #2389 from hugovk/outline

Test ImageDraw.Outline and and ImageDraw.Shape
This commit is contained in:
wiredfool 2017-02-06 16:57:18 +00:00 committed by GitHub
commit cdaa448782
3 changed files with 44 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 B

View File

@ -172,6 +172,50 @@ class TestImageDraw(PillowTestCase):
def test_line2(self):
self.helper_line(POINTS2)
def test_shape1(self):
# Arrange
im = Image.new("RGB", (100, 100), "white")
draw = ImageDraw.Draw(im)
x0, y0 = 5, 5
x1, y1 = 5, 50
x2, y2 = 95, 50
x3, y3 = 95, 5
# Act
s = ImageDraw.Outline()
s.move(x0, y0)
s.curve(x1, y1, x2, y2, x3, y3)
s.line(x0, y0)
draw.shape(s, fill=1)
del draw
# Assert
self.assert_image_equal(
im, Image.open("Tests/images/imagedraw_shape1.png"))
def test_shape2(self):
# Arrange
im = Image.new("RGB", (100, 100), "white")
draw = ImageDraw.Draw(im)
x0, y0 = 95, 95
x1, y1 = 95, 50
x2, y2 = 5, 50
x3, y3 = 5, 95
# Act
s = ImageDraw.Outline()
s.move(x0, y0)
s.curve(x1, y1, x2, y2, x3, y3)
s.line(x0, y0)
draw.shape(s, outline="blue")
del draw
# Assert
self.assert_image_equal(
im, Image.open("Tests/images/imagedraw_shape2.png"))
def helper_pieslice(self, bbox, start, end):
# Arrange
im = Image.new("RGB", (W, H))