猫史档案馆


【Python作品分享】moon cake【作品秀】

用户:WE工作室长WE工作室长查看:0 回复:2 评论:0 创建时间:2022-01-20T18:49:44


【作品展示】

center_image

 

【作品介绍】

moon cake

 

【作品源代码】

import turtle
import time
import random

print('中秋佳节马上就要到啦,中秋节的特色食物是月饼。')
print(' ')
time.sleep(1)
print('你喜欢什么类型的月饼呢?别着急,我都帮你想好啦!')
print(' ')
time.sleep(1)
print('你不可以选择的有:酸辣月饼,榨菜月饼,韭菜月饼,五仁月饼。')
time.sleep(1)
print()
time.sleep(1)
print(3)
time.sleep(1)
print(2)
time.sleep(1)
print(1)
time.sleep(1)
taste = ' '
num = random.randint(1, 4)
if num == 1:
    taste = '酸辣'
if num == 2:
    taste = '榨菜'
if num == 3:
    taste = '韭菜'
if num == 4:
    taste = '五仁'


def goto(x, y):  # 定义提笔的位置
    turtle.penup()  # 将笔提起,移动时无图
    turtle.goto(x, y)
    turtle.pendown()  # 将笔放下,移动时绘图。


def yuebing_wai():
    turtle.pensize(20)  # 画笔调粗点
    turtle.color("#F8CD32", "#FBA92D")  # 填充颜色,F8CD32是圆圈的边缘颜色,FBA92D是圆圈的填充颜色
    goto(0, -200)  # 画笔起点位于(0,0)点的下方200向量处
    turtle.begin_fill()  # 准备开始填充
    turtle.circle(2)  # 定义半径
    turtle.end_fill()  # 填充结束


def yuebing_zhong():
    goto(0, 0)  # 画笔起点位于(0,0)处
    turtle.color("#F0BE7C")
    for _ in range(20):  # _是占位符,表示临时变量,仅用一次,后面无需再用到
        turtle.right(18)  # 顺时针移动18度
        turtle.begin_fill()
        turtle.forward(150)  # 向前移动的距离
        turtle.circle(40, 180)  # 上一条向前移动220之后,开始画半径40的半圆
        turtle.goto(0, 0)  # 画完半圆之后回到(0,0)
        turtle.right(360)  # 顺时针转个360度
        turtle.end_fill()


def yuebing_nei():  # 逻辑同上
    turtle.right(360)
    turtle.color('#F5E16F')  # 内层颜色
    goto(0, -152)
    for _ in range(12):
        turtle.begin_fill()
        turtle.circle(50, 120)
        turtle.left(180)
        turtle.circle(50, 120)
        turtle.end_fill()


def word():
    global taste
    turtle.right(50)
    goto(-60, -20)  # 更高坐标尽量使字靠中间
    turtle.color("Gold")  # 颜色
    turtle.write(taste, font=("华文隶书", 50, "bold"))
    # turtle.hide()
    turtle.done()


if __name__ == '__main__':
    turtle.speed(90)
    yuebing_zhong()
    yuebing_wai()
    yuebing_nei()
    word()



 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
WE工作室长WE工作室长

666

 

点赞0


评论


WE工作室长WE工作室长

center_image

点赞0


评论