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()
标签:turtle,draw,goto,月饼,Python,write,color,font,size 来源: https://blog.csdn.net/Ajdjdj/article/details/120391265