用户:漩涡鸣人狐仙查看:0 回复:0 评论:0 创建时间:2021-11-23T14:17:50
【作品展示】

【作品介绍】
北斗七星
【作品源代码】
import turtle
import random
mypen = turtle.Pen()
mypen.hideturtle()
mypen.speed(0000000000000000000000000000000000000)
myscreen = turtle.Screen()
myscreen.tracer(0)
myscreen.bgcolor("midnightblue")
#画笔移动
def moveto(x,y):
mypen.penup()
mypen.goto(x,y)
mypen.pendown()
moveto(-200,200)
#画月亮
mypen.pencolor("lightyellow")
mypen.dot(100)
mypen.forward(30)
mypen.pencolor("midnightblue")
mypen.dot(100)
#定义画星星的函数
def star(e,color):
mypen.pencolor(color)
mypen.begin_fill()
mypen.fillcolor(color)
for i in range(5):
mypen.forward(e)
mypen.left(72)
mypen.forward(e)
mypen.right(144)
mypen.end_fill()
def ran():
colors = ['red', 'yellow', 'gold', 'pink','lightskyblue', 'white', 'coral']
color = random.choice(colors)
e = random.randint(3, 8)
return e,color
#存储星星坐标和大小
def d_s(x,y):
e,color = ran()
moveto(x, y)
star(e,color)
def sd(x, y):
e, color = ran()
moveto(x, y)
mypen.dot(e,color)
myscreen.onclick(d_s,btn = 1)
myscreen.onclick(sd, btn=3)
turtle.done()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn