mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 01:04:29 +03:00
Test drawing polygons with sloped and flat lines
This commit is contained in:
parent
f60095f973
commit
3db1944762
BIN
Tests/images/imagedraw_polygon_kite.png
Normal file
BIN
Tests/images/imagedraw_polygon_kite.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 647 B |
|
@ -30,6 +30,8 @@ BBOX2 = [X0, Y0, X1, Y1]
|
||||||
POINTS1 = [(10, 10), (20, 40), (30, 30)]
|
POINTS1 = [(10, 10), (20, 40), (30, 30)]
|
||||||
POINTS2 = [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):
|
class TestImageDraw(PillowTestCase):
|
||||||
|
|
||||||
|
@ -267,6 +269,21 @@ class TestImageDraw(PillowTestCase):
|
||||||
def test_polygon2(self):
|
def test_polygon2(self):
|
||||||
self.helper_polygon(POINTS2)
|
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):
|
def helper_rectangle(self, bbox):
|
||||||
# Arrange
|
# Arrange
|
||||||
im = Image.new("RGB", (W, H))
|
im = Image.new("RGB", (W, H))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user