我试图以这种方式绘制一个三角形,但是我一直搞乱这个部分,我必须选择我的顶点。有人能告诉我哪里出错了吗?
from graphics import GraphicsWindow
triangle1= [[150,50], [250,50],[200,130]]
win = GraphicsWindow(400, 400)
canvas = win.canvas()
canvas.setOutline("blue")
canvas.drawPolygon(triangle1, canvas)
last = len(triangle1) - 1
for i in range(last):
start = triangle1[i]
end = triangle1[i+1]
canvas.drawLine(start[0], start[1], end[0], end[1])
start =triangle1[last]
end = triangle1[0]
canvas.drawLine(start[0], start[1], end[0], end[1])
win.wait()
答案 0 :(得分:0)
如果您使用的是EzGraphics,请尝试:
triangle1 = [150, 50, 250, 50, 200, 130]
canvas.drawPolygon(triangle1)
或
triangle1 = [(150, 50), (250, 50), (200, 130)]
canvas.drawPolygon(triangle1)