用户:
白茶乌龙T537查看:0 回复:0 评论:0 创建时间:2021-09-04T21:44:15
import turtle
# 导入turtle库
t = turtle.Pen()
# 设置t为画笔,简化代码
t.hideturtle()
# 隐藏海龟,美化效果
color = ['red', 'orange', 'yellow', 'green', 'blue', 'purple']
# 准备"颜料"
tx = 80
# x默认值为80
t.pensize(10)
# 设置粗细
turtle.bgcolor('skyblue')
# 设置背景
for x in range(6):
t.setheading(90)
t.penup()
t.setx(tx)
# 确定方向、x坐标和颜色,抬笔防止留下痕迹
t.pencolor(color[x])
t.pendown()
t.speed(1)
t.circle(tx, 180)
# 落笔,画半圆
t.speed(0)
tx = (tx - 10)
# 减去10,半圆半径变小
t.penup()
t.setx(90)
t.setheading(180)
t.pencolor('skyblue')
t.pendown()
t.speed(0)
t.forward(180)
# 删除多余部分
turtle.done()
# 结束~