-1

I am trying to draw a narrow filled arc in python--the height is small and the width is very wide. I want it to startX at 250, startY at 550, i want the width to be 245, the height to be 15... and then I am stuck.

I have tried a few different things for the start/angle but it doesn't look right: 0/90.

I just want it to be a straight horizontal line with a small arc attached to make a semi-circle.

Here is an example of what I tried:

             addArcFilled(pic, 250, 550,245,15, 0, 90, blue)
JenTen10
  • 123
  • 1
  • 2
  • 9
  • Please elaborate a bit on your output device: do you want to put the Arc on some kind of matplotlib chart, or may be you are using some GUI framework (please specify wich one)? – Timofey Chernousov Oct 22 '17 at 03:27
  • I'm actually trying to add an arc to a picture--i am trying to lay it over another element of a picture. Thank you for your response! – JenTen10 Oct 22 '17 at 12:19

1 Answers1

0

@knells Probably this functions does exactly what you need: http://pillow.readthedocs.io/en/3.1.x/reference/ImageDraw.html#PIL.ImageDraw.PIL.ImageDraw.Draw.arc

IL.ImageDraw.Draw.arc(xy, start, end, fill=None) Draws an arc (a portion of a circle outline) between the start and end angles, inside the given bounding box.

PIL.ImageDraw.Draw.chord(xy, start, end, fill=None, outline=None) Same as arc(), but connects the end points with a straight line.

Sample code below:

from PIL import Image, ImageDraw
# get an image
im = Image.open('test.png').convert('RGBA')

# create draw context and draw arc
draw = ImageDraw.Draw(im)
draw.chord([10,10, 200, 200], 0,45, fill=0)
del draw

im.save('test_out.png', "PNG")

im.show()
Timofey Chernousov
  • 1,284
  • 8
  • 12
  • Thank you--this is working! I needed the sample code you provided to see how the arc function works. This is great! Thanks again! – JenTen10 Oct 23 '17 at 07:50