如何用PIL画三角形?
how to draw a triangle with PIL?
我正在尝试使用 PIL ImageDraw 绘制三角形
这是我的代码
t1 = int(tri[0])
t2 = int(tri[1])
t3 = int(tri[2])
t4 = int(tri[3])
t5 = int(tri[4])
t6 = int(tri[5])
t7 = int(tri[6])
t8 = int(tri[7])
t9 = int(tri[8])
t10 = int(tri[9])
draw.polygon((t1,t2),(t3,t4),(t5,t6), fill=(t7,t8,t9,t10))
我收到错误
TypeError: polygon() got multiple values for argument 'fill'
有什么方法可以在不出现此错误的情况下制作三角形
python 2.7
像这样:
from PIL import Image,ImageDraw
# Create empty black canvas
im = Image.new('RGB', (255, 255))
# Draw red and yellow triangles on it and save
draw = ImageDraw.Draw(im)
draw.polygon([(20,10), (200, 200), (100,20)], fill = (255,0,0))
draw.polygon([(200,10), (200, 200), (150,50)], fill = 'yellow')
im.save('result.png')
draw.polygon(((t1,t2),(t3,t4),(t5,t6)), fill=(t7,t8,t9,t10))
而不是
draw.polygon((t1,t2),(t3,t4),(t5,t6), fill=(t7,t8,t9,t10))
缺少括号
我正在尝试使用 PIL ImageDraw 绘制三角形 这是我的代码
t1 = int(tri[0])
t2 = int(tri[1])
t3 = int(tri[2])
t4 = int(tri[3])
t5 = int(tri[4])
t6 = int(tri[5])
t7 = int(tri[6])
t8 = int(tri[7])
t9 = int(tri[8])
t10 = int(tri[9])
draw.polygon((t1,t2),(t3,t4),(t5,t6), fill=(t7,t8,t9,t10))
我收到错误
TypeError: polygon() got multiple values for argument 'fill'
有什么方法可以在不出现此错误的情况下制作三角形
python 2.7
像这样:
from PIL import Image,ImageDraw
# Create empty black canvas
im = Image.new('RGB', (255, 255))
# Draw red and yellow triangles on it and save
draw = ImageDraw.Draw(im)
draw.polygon([(20,10), (200, 200), (100,20)], fill = (255,0,0))
draw.polygon([(200,10), (200, 200), (150,50)], fill = 'yellow')
im.save('result.png')
draw.polygon(((t1,t2),(t3,t4),(t5,t6)), fill=(t7,t8,t9,t10))
而不是
draw.polygon((t1,t2),(t3,t4),(t5,t6), fill=(t7,t8,t9,t10))
缺少括号