源码见:https://want595.blog.csdn.net/
1.底盘
在制作蛋糕之前咱们需要先找到一个好看的盘子吖~
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()
2.蛋糕
找到了我们喜欢的盘子后,咱们就可以一层层制作蛋糕啦!
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()
3.祝福
最最最重要滴,一定不要忘记写下对她的祝福吖!
t.write("Happy Birthday!", font=("Curlz MT", 50))