猫史档案馆


【Python作品分享】新的作品

用户:CrystaloClACrystaloClA查看:0 回复:0 评论:0 创建时间:2022-05-19T12:41:37


【作品展示】

center_image

 

【作品介绍】

刘畊宏女孩

 

【作品源代码】

import turtle 
from random import randint, random
xclick = 0
yclick = 0
t =turtle.Pen()
def draw_star(points, size, col, x, y):
    t.penup()
    t.goto(x,y)
    t.pd()
    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 getcoordinates():
    turtle.onscreenclick(mod)


def mod(rawx, rawy):
    global xclick
    global yclick
    xclick = int(rawx//1)
    yclick = int(rawy//1)
    return(xclick)
    return(yclick)

# Main code
turtle.Screen().bgcolor('dark blue')
t.speed(0)
while True:
    
    getcoordinates()
    ranX = xclick
    ranY = yclick
    ranPts = randint(2, 5) * 2 + 1
    ranSize = randint(10,50)
    ranCol = (random(),random(),random())
    draw_star(ranPts, ranSize, ranCol, ranX, ranY) 
turtle.done()

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页