Skip to content
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

Clarify that line() and polygon() include xy pixels #7142

Merged
merged 1 commit into from
May 12, 2023

Conversation

radarhere
Copy link
Member

Resolves #367

#6625 documented that ImageDraw's rectangle() included the endpoints. This continues that clarification of the documentation for line() and polygon().

As a demonstration, see the following code comparing the three functions.

from PIL import Image, ImageDraw

img = Image.new('RGB', (10, 10), (255, 255, 255))
draw = ImageDraw.Draw(img, 'RGBA')
draw.polygon([(2,2), (2, 8), (8,8), (8, 2)], fill=(0, 255, 0, 127))
draw.rectangle([(2,2), (8,8)], fill=(255, 0, 0, 127))
draw.line([(2,2), (8,8)], fill=(0, 0, 0, 255))

img.resize((200, 200), Image.NONE).save("out.png")

@@ -243,6 +243,7 @@ Methods
.. py:method:: ImageDraw.line(xy, fill=None, width=0, joint=None)

Draws a line between the coordinates in the ``xy`` list.
The coordinate pixels are included in the drawn line.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a bit clearer?

Suggested change
The coordinate pixels are included in the drawn line.
The endpoint coordinate pixels are included in the drawn line.

Or simply?

Suggested change
The coordinate pixels are included in the drawn line.
The endpoint pixels are included in the drawn line.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to update it with any wording that you think is clearer, but both line() and polygon() accept a series of coordinates. I wonder if saying 'endpoint' implies it is only the first and last of those coordinates that are included?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, good point. Not sure now! Let's stick with the original :)

@@ -287,7 +288,7 @@ Methods

The polygon outline consists of straight lines between the given
coordinates, plus a straight line between the last and the first
coordinate.
coordinate. The coordinate pixels are included in the drawn polygon.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
coordinate. The coordinate pixels are included in the drawn polygon.
coordinate. The endpoint coordinate pixels are included in the drawn polygon.
Suggested change
coordinate. The coordinate pixels are included in the drawn polygon.
coordinate. The endpoint pixels are included in the drawn polygon.

@hugovk hugovk merged commit 0efd72d into python-pillow:main May 12, 2023
@radarhere radarhere deleted the imagedraw branch May 13, 2023 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vertical lines drawn with draw.line have one extra width pixel
2 participants