赞
踩
hello,大家好,我是wangzirui32,今天我们来学习如何使用turtle绘制奥运五环,开始学习吧!
import turtle
turtle.hideturtle() # 隐藏绘图小海龟
def draw_a_circle(x, y, color):
turtle.penup() # 提笔
turtle.goto(x, y) # 前往x, y处开始绘图
turtle.pensize(5) # 画布粗细为5
turtle.pencolor(color) # 设置画笔颜色
turtle.pendown() # 下笔
turtle.circle(70) # 绘制一个半径为70的圆
turtle.penup() # 提笔
draw_a_circle(-130, 75, "cyan") # 在-130, 75处绘制颜色为cyan的圆
draw_a_circle(-10, 75, "black") # 在-10, 75处绘制颜色为black的圆
draw_a_circle(110, 75, "red") # 在-110, 75处绘制颜色为red的圆
draw_a_circle(-60, -20, "yellow") # 在-60, -20处绘制颜色为yellow的圆
draw_a_circle(60, -20, "lightgreen") # 在60, -20处绘制颜色为lightgreen的圆
turtle.mainloop() # 持续显示turtle窗口
import turtle turtle.hideturtle() turtle.pensize(8) def draw_a_circle(x, y, color): turtle.penup() turtle.goto(x, y) turtle.pensize(5) turtle.pencolor(color) turtle.pendown() turtle.circle(70) turtle.penup() draw_a_circle(-130, 75, "cyan") draw_a_circle(-10, 75, "black") draw_a_circle(110, 75, "red") draw_a_circle(-60, -20, "yellow") draw_a_circle(60, -20, "lightgreen") turtle.mainloop()
好了,今天的课程就到这里,我是wangzirui32,喜欢的可以点个收藏和关注,我们下次再见!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。