mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-14 05:36:48 +03:00
Only draw each rectangle outline pixel once
This commit is contained in:
parent
058b8d3d12
commit
c0ee869c2c
BIN
Tests/images/imagedraw_rectangle_translucent_outline.png
Normal file
BIN
Tests/images/imagedraw_rectangle_translucent_outline.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 235 B |
|
@ -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")
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user