Improve ImageDraw2 shape methods#8265
Merged
hugovk merged 3 commits intopython-pillow:mainfrom Aug 1, 2024
Merged
Conversation
Member
|
Thanks, this makes the API easier to use 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some improvements to ImageDraw2.
ellipse()only requiresxy,Pillow/src/PIL/ImageDraw2.py
Line 132 in 8f62fbd
but that is not the case.
gives
So I've made a change to add
penas a required argument toarc()and other methods.Some of our test code does pass through
penasNone, and uses thebrushargument for thePeninstead.Pillow/Tests/test_imagedraw2.py
Lines 115 to 120 in 8f62fbd
But even if
penisNone, the fact thatbrushneeds to come afterwards means that a value forpenis still required.arc()does not work.Pillow/src/PIL/ImageDraw2.py
Line 114 in 8f62fbd
>>> from PIL import Image, ImageDraw2 >>> im = Image.new("RGB", (1, 1)) >>> d = ImageDraw2.Draw(im) >>> d.arc((0, 0), 0, 180) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PIL/ImageDraw2.py", line 121, in arc self.render("arc", xy, start, end, *options) File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PIL/ImageDraw2.py", line 107, in render getattr(self.draw, op)(xy, fill=fill, outline=outline) TypeError: arc() got an unexpected keyword argument 'outline'This is because ImageDraw2
render()passesoutlineto every method except forline(), but ImageDrawarc()doesn't accept that.Pillow/src/PIL/ImageDraw2.py
Lines 104 to 107 in 8f62fbd
Pillow/src/PIL/ImageDraw.py
Lines 174 to 181 in 8f62fbd
I've made a change for that.
startandendparameters aren't passed through to ImageDraw. I've added**kwargstorender()to allow them to be added.