【问题标题】:Error while drawing a ellipse with python PIL.ImageDraw使用 python PIL.ImageDraw 绘制椭圆时出错
【发布时间】:2020-02-06 18:44:50
【问题描述】:

我使用这段代码打开一个窗口并在特定位置为图形绘制顶点:

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") 

并得到错误:

ellipse() got multiple values for argument 'fill'

即使填充只有一个参数。

【问题讨论】:

    标签: python python-imaging-library


    【解决方案1】:

    我怀疑你调用错误的函数。请参阅documentation,它建议您将坐标作为列表中的两个元组传递:

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

    我相信正在发生的事情是将您传入的第二组点作为fill 的参数并抱怨它是一个 2 元组,而它需要一个字符串。

    【讨论】:

    • 是的,这正是问题所在
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多