使用Python进行图像编程,要使用到Graphics库。下面列举出较常用的代码
from graphics import *
#设置画布窗口名和尺寸
win = GraphWin('hehe', 666, 666)
#关闭画布窗口
win.getMouse()
win.close()
#画点
pt = Point(100, 100)
pt.draw(win)
#画圆
cir = Circle(Point(200, 200), 75)
cir.draw(win)
cir.setOutline('red') #外围轮廓颜色
cir.setFill('yellow') #填充颜色
#画线
line = Line(Point(650, 100), Point(250, 100))
line.draw(win)
#画矩形
rect = Rectangle(Point(300, 300), Point(400, 400))
rect.setFill('red') #填充颜色
rect.draw(win)
#画椭圆
oval = Oval(Point(450, 450), Point(600, 600))
ova