Skip to content

Commit

Permalink
Only draw each rectangle outline pixel once
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Jan 5, 2021
1 parent d374015 commit e97c26e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions Tests/test_imagedraw.py
Expand Up @@ -699,6 +699,21 @@ def test_rectangle_I16():
)


def test_rectangle_translucent_outline():
# Arrange
im = Image.new("RGB", (W, H))
draw = ImageDraw.Draw(im, "RGBA")

# Act
draw.rectangle(BBOX1, fill="black", outline=(0, 255, 0, 127), width=5)

# Assert
with Image.open(
"Tests/images/imagedraw_rectangle_translucent_outline.png"
) as expected:
assert_image_equal(im, expected)


def test_floodfill():
red = ImageColor.getrgb("red")

Expand Down
4 changes: 2 additions & 2 deletions src/libImaging/Draw.c
Expand Up @@ -724,8 +724,8 @@ ImagingDrawRectangle(
for (i = 0; i < width; i++) {
draw->hline(im, x0, y0 + i, x1, ink);
draw->hline(im, x0, y1 - i, x1, ink);
draw->line(im, x1 - i, y0, x1 - i, y1, ink);
draw->line(im, x0 + i, y1, x0 + i, y0, ink);
draw->line(im, x1 - i, y0 + width, x1 - i, y1 - width + 1, ink);
draw->line(im, x0 + i, y0 + width, x0 + i, y1 - width + 1, ink);
}
}

Expand Down

0 comments on commit e97c26e

Please sign in to comment.