猫史档案馆


【Python作品分享】浩瀚星海【作品秀】

用户:一只红蒂罢了一只红蒂罢了查看:0 回复:0 评论:0 创建时间:2020-06-30T22:49:57


【作品展示】

center_image

 

【作品介绍】

一个用来画星海的程序,有五角星、三角形、四边形。

 

【作品源代码】

import turtle
import random
import turtle,random


a = turtle.Pen()
a.speed(100)
color = ['red', 'yellow', 'green', 'pink', 'blue', 'white', 'lightgreen', 'orange', 'purple']
turtle.bgcolor("#000000")
a.hideturtle()
while (1 == 1):
    a.setheading(random.randint(0, 360))
    c = random.randint(10, 20)
    a.penup()
    a.goto(random.randint((-200), 200), random.randint((-200), 200))
    yanse = random.choice(color)
    a.pencolor(yanse)
    a.fillcolor(yanse)
    a.pendown()
    if (random.randint(1, 2) == 1):
        a.begin_fill()
        for b in range(5):
            a.forward(c)
            a.right(144)
        a.end_fill()
    elif (random.randint(1, 2) == 1):
        a.begin_fill()
        a.circle(c, steps=3)
        a.end_fill()
    else:
        a.begin_fill()
        a.circle(c, steps=4)
        a.end_fill()
turtle.done()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页