Python生日蛋糕

目录


前言 

Hello,小伙伴们晚上好吖!前两天博主满20岁啦(要开始奔三辽呜呜呜),这几天收到了不少小伙伴们的祝福,浪漫的小博主想送给大家一份不一样的生日蛋糕,感谢大家对俺滴支持!

底盘

在制作蛋糕之前咱们需要先找到一个好看的盘子吖~

def ground_floor(width,height,colors_a,h):
    t.penup()
    t.goto(width, h)
    t.pendown()
    t.begin_fill()
    t.fillcolor(colors_a[0])
    for i in range(360):
        x=draw_x(width, i)
        y=draw_y(height,i)+h
        t.goto(x,y)
    t.end_fill()
    t.begin_fill()
    t.fillcolor(colors_a[1])
    for i in range(180):
        x=draw_x(width, -i)
        y=draw_y(height+10,-i)+h
        t.goto(x,y)
    for i in range(180,360):
        x=draw_x(width, i)
        y=draw_y(height,i)+h
        t.goto(x,y)
    t.end_fill()

蛋糕

找到了我们喜欢的盘子后,咱们就可以一层层制作蛋糕啦! 

def each_piece(width,height_1,height_2,colors_b,h):
    t.penup()
    t.goto(width,h)
    t.pendown()
    t.begin_fill()
    t.fillcolor(colors_b[0])
    for i in range(360):
        x=draw_x(width, i)
        y=draw_y(height_1,i)+h
        t.goto(x,y)
    t.end_fill()
    t.begin_fill()
    t.fillcolor(colors_b[0])
    for i in range(540):
        x=draw_x(width, i)
        y=draw_y(height_1,i)+height_2+h
        t.goto(x,y)
    t.goto(-width,h)
    t.end_fill()
    t.penup()
    t.goto(width-10,height_2+h)
    t.pendown()
    t.begin_fill()
    t.fillcolor(colors_b[1])
    for i in range(360):
        x=draw_x(width - 10, i)
        y=draw_y(height_1*0.9,i)+height_2+h
        t.goto(x,y)
    t.end_fill()
    t.penup()
    t.goto(width,h)
    t.pendown()
    t.begin_fill()
    t.fillcolor(colors_b[2])
    for i in range(180):
        x=draw_x(width, -i)
        y=draw_y(height_1,-i)+10+h
        t.goto(x,y)
    t.goto(-width,h)
    for i in range(180,360):
        x=draw_x(width, i)
        y=draw_y(height_1,i)+h
        t.goto(x,y)
    t.end_fill()
    t.penup()
    t.goto(width,height_2+h)
    t.pendown()
    t.begin_fill()
    t.fillcolor(colors_b[3])
    for i in range(1800):
        x=draw_x(width, 0.1 * i)
        y=draw_y(-height_1*0.3,i)+h
        t.goto(x,y)
    t.goto(-width,height_2+h)
    for i in range(180,360):
        x=draw_x(width, i)
        y=draw_y(height_1,i)+height_2+h
        t.goto(x,y)
    t.end_fill()

蜡烛 

蛋糕完成后不要忘记制作蜡烛喔~

祝福 

最最最重要滴,一定不要忘记写下对她的祝福吖! 

t.write("Happy Birthday!", font=("Curlz MT", 50)) 

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
心中带点小风骚的头像心中带点小风骚普通用户
上一篇 2023年4月22日
下一篇 2023年4月22日

相关推荐