Only draw each rectangle outline pixel once

This commit is contained in:
Andrew Murray 2021-02-22 07:48:58 +11:00
parent 058b8d3d12
commit c0ee869c2c
3 changed files with 16 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

View File

@ -692,6 +692,20 @@ def test_rectangle_I16():
assert_image_equal_tofile(im.convert("I"), "Tests/images/imagedraw_rectangle_I.png") 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(): def test_floodfill():
red = ImageColor.getrgb("red") red = ImageColor.getrgb("red")

View File

@ -724,8 +724,8 @@ ImagingDrawRectangle(
for (i = 0; i < width; i++) { for (i = 0; i < width; i++) {
draw->hline(im, x0, y0 + i, x1, ink); draw->hline(im, x0, y0 + i, x1, ink);
draw->hline(im, x0, y1 - i, x1, ink); draw->hline(im, x0, y1 - i, x1, ink);
draw->line(im, x1 - i, y0, x1 - i, y1, ink); draw->line(im, x1 - i, y0 + width, x1 - i, y1 - width + 1, ink);
draw->line(im, x0 + i, y1, x0 + i, y0, ink); draw->line(im, x0 + i, y0 + width, x0 + i, y1 - width + 1, ink);
} }
} }