mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-11 17:56:18 +03:00
Merge pull request #8165 from radarhere/imagedraw2_error
This commit is contained in:
commit
ad4c23bddd
|
@ -57,6 +57,14 @@ def test_sanity() -> None:
|
|||
draw2.line(list(range(10)), pen)
|
||||
|
||||
|
||||
def test_mode() -> None:
|
||||
draw = ImageDraw2.Draw("L", (1, 1))
|
||||
assert draw.image.mode == "L"
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
ImageDraw2.Draw("L")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("bbox", BBOX)
|
||||
def test_ellipse(bbox: Coords) -> None:
|
||||
# Arrange
|
||||
|
|
|
@ -56,8 +56,16 @@ class Draw:
|
|||
(Experimental) WCK-style drawing interface
|
||||
"""
|
||||
|
||||
def __init__(self, image, size=None, color=None):
|
||||
if not hasattr(image, "im"):
|
||||
def __init__(
|
||||
self,
|
||||
image: Image.Image | str,
|
||||
size: tuple[int, int] | list[int] | None = None,
|
||||
color: float | tuple[float, ...] | str | None = None,
|
||||
) -> None:
|
||||
if isinstance(image, str):
|
||||
if size is None:
|
||||
msg = "If image argument is mode string, size must be a list or tuple"
|
||||
raise ValueError(msg)
|
||||
image = Image.new(image, size, color)
|
||||
self.draw = ImageDraw.Draw(image)
|
||||
self.image = image
|
||||
|
|
Loading…
Reference in New Issue
Block a user