猫史档案馆


【Python作品分享】星空【作品秀】

用户:温和的萌萌熊HefA温和的萌萌熊HefA查看:9 回复:1 评论:9 创建时间:2021-10-01T09:49:17


【作品展示】

center_image

 

【作品介绍】

星空

 

【作品源代码】

import turtle as t
from random import randint,random
t.speed(0)

def draw_star(points,size,col,x,y):
    t.penup()
    t.goto(x,y)
    t.pendown
    angle=180-(180/points)
    t.color(col)
    t.begin_fill()
    for i in range(points):
        t.forward(size)
        t.right(angle)
    t.end_fill()

def draw_planet(col,x,y):
    t.penup()
    t.goto(x,y)
    t.pendown()
    t.color(col)
    t.begin_fill()
    t.circle(50)
    t.end_fill()

#Main code
t.Screen().bgcolor('dark blue')
t.hideturtle()

while True:
    ranPts=randint(2,5)*2+1
    ranSize=randint(10,50)
    ranCol=(random(),random(),random())
    ranX=randint(-350,300)
    ranY=randint(-250, 250)

    draw_star(ranPts,ranSize,ranCol,ranX,ranY)

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
Python-happyyyyPython-happyyyy

原来初一的题那么简单(doge)

点赞0


评论