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 Feb 21, 2021
1 parent 058b8d3 commit c0ee869
Show file tree
Hide file tree
Showing 3 changed files with 16 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.
14 changes: 14 additions & 0 deletions Tests/test_imagedraw.py
Expand Up @@ -692,6 +692,20 @@ def test_rectangle_I16():
assert_image_equal_tofile(im.convert("I"), "Tests/images/imagedraw_rectangle_I.png")


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
assert_image_equal_tofile(
im, "Tests/images/imagedraw_rectangle_translucent_outline.png"
)


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 c0ee869

Please sign in to comment.