theicepheonix
theicepheonix

Reputation: 58

Error while drawing a ellipse with python PIL.ImageDraw

I used this code to open a window and draw vertices for a graph in a specific place:

def draw_field(field):
    img = Image.new("RGB", (800,600), (255,255,255))
    draw = ImageDraw.Draw(img)
    for i in vertices:
        draw.ellipse((10, 10), (i[1], i[3]), fill ="blue", outline ="green") 

and got the error:

ellipse() got multiple values for argument 'fill'

even though there was only one argument for fill.

Upvotes: 2

Views: 290

Answers (1)

Mihai Chelaru
Mihai Chelaru

Reputation: 8187

I suspect you're calling the function wrong. See the documentation, which suggests you should pass the coordinates as two tuples inside a list:

draw.ellipse([(10, 10), (i[1], i[3])], fill ="blue", outline ="green")

I believe what's happening is it's taking the second set of points you're passing in as the argument to fill and complaining that it's a 2-tuple, when it expects a string.

Upvotes: 1

Related Questions