python使用turtle绘制奥运五环

您所在的位置:网站首页 奥运五环手镯 python使用turtle绘制奥运五环

python使用turtle绘制奥运五环

2024-03-15 02:29| 来源: 网络整理| 查看: 265

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()


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3