python使用turtle绘制奥运五环

python使用turtle绘制奥运五环

奥林匹克标志中五个环的大小,颜色,间距有固定的比例,规定圆的半径为45,五个圆的起始坐标为(-110,-25),(0,-25),(110,-25),(-55,-75),(55,-75),五环的颜色分别为red, blue, green, yellow, black.提示:turtle goto(x,y)函数,能够将turtle画笔移动到坐标(x,y)。

代码块如下:

import turtle
r=45
xy_list=[(-110,-25),(0,-25),(110,-25),(-55,-75),(55,-75)]
color_list=['red','yellow','green','blue','black']
turtle.pensize(5)
for i in range(5):
   turtle.penup()
   turtle.goto(xy_list[i][0],xy_list[i][1])
   turtle.pendown()   #绘制图案
   turtle.color(color_list[i])
   turtle.circle(r)
   turtle.begin_fill()
turtle.end_fill()
turtle.hideturtle()
turtle.done()

猜你喜欢

转载自blog.csdn.net/m0_74459049/article/details/129344087