猫史档案馆


【Python作品分享】给猫站de礼物

用户:褚岩分身褚岩分身查看:4 回复:2 评论:4 创建时间:2022-03-09T19:28:58


【作品展示】

center_image

 

【作品介绍】

祝猫站七周年生日快乐!——迟来de祝福。

 

【作品源代码】

import turtle
import time
import random
# .............
t = turtle.Pen()
t.hideturtle()
s = turtle.Screen()
s.tracer(0)
s.bgcolor('#ffff99')
s.setup(1900, 1000)

j = 3
n = (360 / j)
a = ((360 / n) / 4)
i = 0


def moveto(x, y):
    t.penup()
    t.goto(x, y)
    t.pendown()

def heat(color):
    t.setheading(90)
    t.pencolor(color)
    # 开始填充
    t.begin_fill()
    # 填充颜色
    t.fillcolor(color)
    t.right(45)
    l = 100
    i = 0
    while (i < 4):
        t.forward(l)
        t.left(90)
        i = (i + 1)
    # 结束填充
    t.end_fill()

    t.forward(l)
    t.left(90)
    t.forward((l / 2))
    t.dot(l)

    t.forward((l / 2))
    t.left(90)
    t.forward((l / 2))
    t.dot(l)

    t.right(90)
    t.forward((l / 4))
    t.pencolor('white')
    t.dot((l / 10))

    t.right(90)
    # 抬笔
    t.penup()
    t.forward((l / 6))
    # 落笔
    t.pendown()
    t.dot((l / 8))


moveto(-500,0)
t.pencolor('white')
t.write('祝猫站七周年快乐!', font=('文泉驿正黑', 100))

def random_heat():
    colors=['red', 'green', 'blue', 'gold', 'violet', 'yellow','lightskyblue','tomato']
    color=random.choice(colors)
    return color

def draw_heat(x, y):
    color=random_heat()
    moveto(x, y)
    heat(color)
s.onclick(draw_heat)

t.hideturtle()
turtle.done()

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
SCS_user_hReUGvaUydSCS_user_hReUGvaUyd

WIN7好评(我也是)

点赞0


评论


伴雪纷飞伴雪纷飞

很无语....

点赞0


评论