Python turtle画月饼

import turtle as t


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


def draw_edges(x, y, color):
    count = 20
    length = 210
    t.color(color)
    goto(x, y)
    for foo in range(count):
        t.right(360 / count)
        t.begin_fill()
        t.fd(length)
        t.circle(40, 180)
        t.end_fill()
        goto(x, y)


def draw_circle():
    goto(0, -190)
    t.pensize(5)
    t.color(shadow)
    t.circle(190)


def draw_font():
    t.color(shadow)
    size = 80
    goto(-size / 2, 80)
    font = ('kaiti', size, 'bold')
    t.write('豆', font=font)
    goto(-size / 2, -80 - size)
    t.write('沙', font=font)

    size = 50
    content = '海上生明月  天涯共此时'
    len_ = len(content) + 2
    t.color('red')
    goto(-len_ * size / 2, -400)
    font = ('kaiti', size, 'bold')
    t.write(content, font=font)


color = 'khaki'
shadow = '#d9b300'
t.speed(1000)
draw_edges(-25, 25, shadow)
draw_edges(0, 0, color)
draw_circle()
write()

t.done()
上一篇:自定义一个函数,调用函数,在鼠标右键按下时,出现不同大小的红色五角星


下一篇:21206125-孙琪-九月二十日 python学习总结(三)