News from this site

 Rental advertising space, please contact the webmaster if you need cooperation


+focus
focused

classification  

no classification

tag  

no tag

date  

2024-11(6)

Python生日蛋糕

posted on 2023-05-21 17:14     read(303)     comment(0)     like(0)     collect(0)


Table of contents

foreword 

chassis

cake

Candle 

bless 


foreword 

Hello, friends, good evening! The blogger turned 20 years old two days ago (starting to go to Sanliao woo woo woo), and has received many blessings from friends these days. The romantic little blogger wants to give everyone a different birthday cake , Thank you all for supporting me!

chassis

Before making the cake, we need to find a good-looking plate~

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()

cake

After finding a plate we like, we can make the cake layer by layer! 

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()

Candle 

Don't forget to make candles after the cake is finished~

bless 

Most importantly, don't forget to write down your best wishes to her! 

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



Category of website: technical article > Blog

Author:Poison

link:http://www.pythonblackhole.com/blog/article/25270/10da55f77532a9174f14/

source:python black hole net

Please indicate the source for any form of reprinting. If any infringement is discovered, it will be held legally responsible.

0 0
collect article
collected

Comment content: (supports up to 255 characters)