-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draw arc, pieslice and ellipse silently fail with some coordinates #3029
Comments
To check that you've seen this, and to mention it here as part of the discussion, you think this doesn't adequately explain the argument? |
it does but it could be a lot clearer, at a quick glance it could easily be interpreted as x and y of first coord and x and y of second, with no clear restrictions as to needing to in ascending order. |
Okay, let me try again. I found this? https://pillow.readthedocs.io/en/latest/handbook/concepts.html#coordinate-system |
Here's the same code, but a fuller example with bigger numbers and different colours. Only the white arc is drawn: from PIL import Image, ImageDraw
im = Image.new("RGB", (120, 120))
draw = ImageDraw.Draw(im)
draw.arc((0, 0, 100, 100), 0, 90, 'white') # works
draw.arc((100, 0, 0, 100), 0, 90, 'red') # doesn't work
draw.arc((0, 100, 100, 0), 0, 90, 'green') # doesn't work
draw.arc((100, 100, 0, 0), 0, 90, 'blue') # doesn't work
im.show() It doesn't matter if you do draw.arc(((0, 0), (100, 100)), 0, 90, 'white') # works
draw.arc(((100, 0), (0, 100)), 0, 90, 'red') # doesn't work
draw.arc(((0, 100), (100, 0)), 0, 90, 'green') # doesn't work
draw.arc(((100, 100), (0, 0)), 0, 90, 'blue') # doesn't work Here are the four coordinates: Opposite corners are used in different combinations, and I might expect different arcs, but it's the same square and I might expect some sort of arc drawn for each. Arcs are drawn using this Lines 735 to 838 in 81c88b1
Which is also used for ImageDraw.ellipse , chord and pieslice , which similarly only draw the white one.
And right at the top it calculates the Lines 750 to 753 in 81c88b1
Commenting out that We could "fix" it like this, but remember each arc is drawing from 0 to 90 degrees, so it's kind of twisting depending on how the "direction" the bounding box is defined. I think this could be get quite confusing, and might also break existing code that is written for the current design, which has been like this since at least PIL 1.1.1 (released in 2000). So I propose we better document that the bounding box for these four methods is a "Sequence of |
Re-opening this so it can be closed by PR #3080 :) |
if i try and use the arc, pieslice or ellipse methods of a Draw object with some sets of coordinates no error is raised but nothing is drawn either.
this occurs when one or both axis coordinates decreases between the first and second coord of the bounding box.
eg:
I'm using python3.4 and pillow 5.0.0
I have no issue with the API requiring the coordinates in the correct order, but I couldn't find any documentation stating that it was required, and obviously no error was raised either.
I think it needs documenting and maybe raise an error too?
The text was updated successfully, but these errors were encountered: