From 3db194476245eeafa2c78a7f680cff15082d776a Mon Sep 17 00:00:00 2001 From: Hugo Date: Mon, 15 May 2017 17:09:29 +0300 Subject: [PATCH] Test drawing polygons with sloped and flat lines --- Tests/images/imagedraw_polygon_kite.png | Bin 0 -> 647 bytes Tests/test_imagedraw.py | 17 +++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 Tests/images/imagedraw_polygon_kite.png diff --git a/Tests/images/imagedraw_polygon_kite.png b/Tests/images/imagedraw_polygon_kite.png new file mode 100644 index 0000000000000000000000000000000000000000..e48d6660fe2202e2deec1d5843beb4dfc39d4aec GIT binary patch literal 647 zcmV;20(kw2P)4PPC0GZ2i8AcR*IR=SQEnYFvb{Tj4{TTVmWKiz(qN~j#S=s zygs*#s!`5QN_$bIt)rjm<>=Ru$~h(JAI`n31E7#&S^t8nUm%RjtE`itkUv>XQ1y!? zaXFKv0t&g2H3X{uMloDIWa)xJ)@4nDst1w5Wm=XIP{^n(5m5Dj0=O*7vIYv-k|hqR z9()y-Az5ZYArrE;f~wzW375Vs`=F4ftYe_+H=W0&Cd&~hq##QLR6T)7T&HDu1clDY zQU_HwhwG3m*PzgLS*AdhP2k!qD+VaEOO{zsWuv&Z$O;Au3CnT;s%!|Cq^zi*kc=#M zpvwAj3CIc$3N6WU4XUgY*SxHIK%p5~VL+Aj;2M^7At*E;DZvI zy~ov%MNnmw^;7el_0b$6r6;8)XA`$$b>m;d?|MFGwPhg^<0ts%>HgnvKo+`|7_T}E zT+f=3g>EBu`<2q6Yw%05&?UsKzPmGe-%v&ticRd^JJJ(t9fW0}ki;%sMKiZPYnLn( ziP()R|EAZJZkL4u5W8-*^2$2+bFz?MVs|}ZvH0wcf-K~Yn2Cv=A-4X!p{6Y4g_y1R z?IR}gjI;?^$T%^h(~>17wXcIMS;!_aTeJDwIx)e$XpG82rihuCL{D?XWcSaqE(=*8 z=0+CkCnmnX57{^HbY!x>C h4l>3VV~nxDeF3HkH?Ycoy&M1l002ovPDHLkV1ib~E${#U literal 0 HcmV?d00001 diff --git a/Tests/test_imagedraw.py b/Tests/test_imagedraw.py index 441a34a88..11e990bcb 100644 --- a/Tests/test_imagedraw.py +++ b/Tests/test_imagedraw.py @@ -30,6 +30,8 @@ BBOX2 = [X0, Y0, X1, Y1] POINTS1 = [(10, 10), (20, 40), (30, 30)] POINTS2 = [10, 10, 20, 40, 30, 30] +KITE_POINTS = [(10, 50), (70, 10), (90, 50), (70, 90), (10, 50)] + class TestImageDraw(PillowTestCase): @@ -267,6 +269,21 @@ class TestImageDraw(PillowTestCase): def test_polygon2(self): self.helper_polygon(POINTS2) + def test_polygon_kite(self): + # Test drawing lines of different gradients (dx>dy, dy>dx) and + # vertical (dx==0) and horizontal (dy==0) lines + # Arrange + im = Image.new("RGB", (W, H)) + draw = ImageDraw.Draw(im) + + # Act + draw.polygon(KITE_POINTS, fill="blue", outline="yellow") + del draw + + # Assert + self.assert_image_equal( + im, Image.open("Tests/images/imagedraw_polygon_kite.png")) + def helper_rectangle(self, bbox): # Arrange im = Image.new("RGB", (W, H))