From 008431fe0e6b9489fa8f2553802834b831519bb0 Mon Sep 17 00:00:00 2001 From: hugovk Date: Mon, 30 Jan 2017 21:50:48 +0200 Subject: [PATCH 1/2] Test ImageDraw.Outline curve --- Tests/images/imagedraw_outline_curve.png | Bin 0 -> 454 bytes Tests/test_imagedraw.py | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 Tests/images/imagedraw_outline_curve.png diff --git a/Tests/images/imagedraw_outline_curve.png b/Tests/images/imagedraw_outline_curve.png new file mode 100644 index 0000000000000000000000000000000000000000..0e9f3b412c23ef5c92aed7a7d00b3aef154f3dd4 GIT binary patch literal 454 zcmeAS@N?(olHy`uVBq!ia0vp^DImCx#Z@9pUYxJ`R!FQcNfaocU`_;%jln^b0DH&W5fGb&-cB~+u4`J+imVJ zomGO{Kr8_$bHM7_gYENMLwO-W8w5`uzxHH*^J%7S$(HNRGU;*O=)L-B$G3CuHZ=sS zF*`15vGp_)U(!~ybssAGr(gA3e|YjQBbG%;TMgFDFfMy>|NHts_x=Bf+&KNAR@hlR z>GZ6<2}zvhb{`r4f9YHrTmNWNTL0`DGjG>?TYPx4TG^+p^Lp7~KaXs>b0ue^nyA|8 z9e>YkoR-HE{^DVP!L=ukQe5XRJi1>x?k8WsuX54&YhK?L##S1y>k}1t5pj}zN>|d= q^ZU~ok1_SYz0e;E2EwA-7tm=^=%hr!d;&t;ucLK6TIhq{aa literal 0 HcmV?d00001 diff --git a/Tests/test_imagedraw.py b/Tests/test_imagedraw.py index 6f92ac3a0..fd4c3a104 100644 --- a/Tests/test_imagedraw.py +++ b/Tests/test_imagedraw.py @@ -172,6 +172,28 @@ class TestImageDraw(PillowTestCase): def test_line2(self): self.helper_line(POINTS2) + def test_outline_curve(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_outline_curve.png")) + def helper_pieslice(self, bbox, start, end): # Arrange im = Image.new("RGB", (W, H)) From 96dfd722c32bfc5c49f02639d89caca1e256cb87 Mon Sep 17 00:00:00 2001 From: hugovk Date: Tue, 31 Jan 2017 08:22:33 +0200 Subject: [PATCH 2/2] Test ImageDraw.Outline curve --- ...outline_curve.png => imagedraw_shape1.png} | Bin Tests/images/imagedraw_shape2.png | Bin 0 -> 459 bytes Tests/test_imagedraw.py | 26 ++++++++++++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) rename Tests/images/{imagedraw_outline_curve.png => imagedraw_shape1.png} (100%) create mode 100644 Tests/images/imagedraw_shape2.png diff --git a/Tests/images/imagedraw_outline_curve.png b/Tests/images/imagedraw_shape1.png similarity index 100% rename from Tests/images/imagedraw_outline_curve.png rename to Tests/images/imagedraw_shape1.png diff --git a/Tests/images/imagedraw_shape2.png b/Tests/images/imagedraw_shape2.png new file mode 100644 index 0000000000000000000000000000000000000000..daf0303133080ab9770ea71230241b8ec89c852e GIT binary patch literal 459 zcmeAS@N?(olHy`uVBq!ia0vp^DImqb78PxC@AZ)6LT3pmz2y-mCByp~qz&%IoFtJN+)^5yn@ zleWga;hN~LoO^9oIWF&#-d@HWw%OOOgb0Vi_NJL-DUXt{}W##EA`Cy&eB+t`T8$)!S_SDU1wK^`97`E{8*bv<2wuzB%q2VLR%&C}#$$6rGv2?^i_@% literal 0 HcmV?d00001 diff --git a/Tests/test_imagedraw.py b/Tests/test_imagedraw.py index fd4c3a104..cd6519709 100644 --- a/Tests/test_imagedraw.py +++ b/Tests/test_imagedraw.py @@ -172,7 +172,7 @@ class TestImageDraw(PillowTestCase): def test_line2(self): self.helper_line(POINTS2) - def test_outline_curve(self): + def test_shape1(self): # Arrange im = Image.new("RGB", (100, 100), "white") draw = ImageDraw.Draw(im) @@ -192,7 +192,29 @@ class TestImageDraw(PillowTestCase): # Assert self.assert_image_equal( - im, Image.open("Tests/images/imagedraw_outline_curve.png")) + 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