| import contextlib |
| import os.path |
|
|
| import pytest |
|
|
| from PIL import Image, ImageColor, ImageDraw, ImageFont, features |
|
|
| from .helper import ( |
| assert_image_equal, |
| assert_image_equal_tofile, |
| assert_image_similar_tofile, |
| hopper, |
| skip_unless_feature, |
| ) |
|
|
| BLACK = (0, 0, 0) |
| WHITE = (255, 255, 255) |
| GRAY = (190, 190, 190) |
| DEFAULT_MODE = "RGB" |
| IMAGES_PATH = os.path.join("Tests", "images", "imagedraw") |
|
|
| # Image size |
| W, H = 100, 100 |
|
|
| # Bounding box points |
| X0 = int(W / 4) |
| X1 = int(X0 * 3) |
| Y0 = int(H / 4) |
| Y1 = int(X0 * 3) |
|
|
| # Bounding boxes |
| BBOX = (((X0, Y0), (X1, Y1)), [(X0, Y0), (X1, Y1)], (X0, Y0, X1, Y1), [X0, Y0, X1, Y1]) |
|
|
| # Coordinate sequences |
| POINTS = ( |
| ((10, 10), (20, 40), (30, 30)), |
| [(10, 10), (20, 40), (30, 30)], |
| (10, 10, 20, 40, 30, 30), |
| [10, 10, 20, 40, 30, 30], |
| ) |
|
|
| KITE_POINTS = ( |
| ((10, 50), (70, 10), (90, 50), (70, 90), (10, 50)), |
| [(10, 50), (70, 10), (90, 50), (70, 90), (10, 50)], |
| ) |
|
|
|
|
| def test_sanity(): |
| im = hopper("RGB").copy() |
|
|
| draw = ImageDraw.ImageDraw(im) |
| draw = ImageDraw.Draw(im) |
|
|
| draw.ellipse(list(range(4))) |
| draw.line(list(range(10))) |
| draw.polygon(list(range(100))) |
| draw.rectangle(list(range(4))) |
|
|
|
|
| def test_valueerror(): |
| with Image.open("Tests/images/chi.gif") as im: |
| draw |