1个回答
展开全部
# draw a circle on top of two rectangles
# using module graphics from:
# http://mcsp.wartburg.edu/zelle/python/graphics.py
from graphics import *
# create the window/frame
w = 300
h = 300
win = GraphWin("Red Circle", w, h)
# first rectangle using corner x, y coordinates
upper_left = Point(0, 0)
lower_right = Point(300, 150)
rect1 = Rectangle(upper_left, lower_right)
rect1.setFill('yellow')
rect1.setWidth(0) # no border
rect1.draw(win)
# second rectangle using corner x, y coordinates
upper_left = Point(0, 150)
lower_right = Point(300, 300)
rect2 = Rectangle(upper_left, lower_right)
rect2.setFill('green')
rect2.setWidth(0) # no border
rect2.draw(win)
# circle needs center x, y coordinates and radius
center = Point(150, 150)
radius = 80
circle = Circle(center, radius)
circle.setFill('red')
circle.setWidth(2)
circle.draw(win)
# wait, click mouse to go on/exit
win.getMouse()
win.close()
# using module graphics from:
# http://mcsp.wartburg.edu/zelle/python/graphics.py
from graphics import *
# create the window/frame
w = 300
h = 300
win = GraphWin("Red Circle", w, h)
# first rectangle using corner x, y coordinates
upper_left = Point(0, 0)
lower_right = Point(300, 150)
rect1 = Rectangle(upper_left, lower_right)
rect1.setFill('yellow')
rect1.setWidth(0) # no border
rect1.draw(win)
# second rectangle using corner x, y coordinates
upper_left = Point(0, 150)
lower_right = Point(300, 300)
rect2 = Rectangle(upper_left, lower_right)
rect2.setFill('green')
rect2.setWidth(0) # no border
rect2.draw(win)
# circle needs center x, y coordinates and radius
center = Point(150, 150)
radius = 80
circle = Circle(center, radius)
circle.setFill('red')
circle.setWidth(2)
circle.draw(win)
# wait, click mouse to go on/exit
win.getMouse()
win.close()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询