| 1 | import collections |
| 2 | |
| 3 | import PIL.Image |
| 4 | import PIL.ImageDraw |
| 5 | import PIL.ImageFont |
| 6 | |
| 7 | from .. import utils |
| 8 | |
| 9 | |
| 10 | def ellipse(src, yx1, yx2, fill=None, outline=None, width=0): |
| 11 | dst = utils.numpy_to_pillow(src) |
| 12 | ellipse_(img=dst, yx1=yx1, yx2=yx2, fill=fill, outline=outline, width=width) |
| 13 | return utils.pillow_to_numpy(dst) |
| 14 | |
| 15 | |
| 16 | def ellipse_(img, yx1, yx2, fill=None, outline=None, width=0): |
| 17 | if isinstance(fill, collections.abc.Iterable): |
| 18 | fill = tuple(fill) |
| 19 | if isinstance(outline, collections.abc.Iterable): |
| 20 | outline = tuple(outline) |
| 21 | |
| 22 | draw = PIL.ImageDraw.Draw(img) |
| 23 | |
| 24 | y1, x1 = yx1 |
| 25 | y2, x2 = yx2 |
| 26 | |
| 27 | draw.ellipse([x1, y1, x2, y2], fill=fill, outline=outline, width=width) |