源码:
from turtle import *
#画布为默认大小,将起笔移动到国旗的左上角
penup()
goto(-300,200)
pendown()
#绘制国旗的红色背景矩形
fillcolor("red")
begin_fill()
for i in range(2):
speed(250)
forward(600)
right(90)
forward(400)
right(90)
end_fill()
#将起笔移动到坐标中心,并将起笔方向设置为x轴正方向
penup()
goto(-265,110)
seth(0)
pendown()
#在中央绘制一颗五星
fillcolor('yellow')
begin_fill()
speed(1)
for i in range(5):
speed(250)
forward(30)
left(72)
forward(30)
right(144)
end_fill()
x=["-210","-160","-160","-210"]
y=["180","140","75","25"]
for h in range(4):
penup()
goto(eval(x[h]),eval(y[h]))
seth(0)
pendown()
fillcolor('yellow')
begin_fill()
speed(1)
for i in range(5):
speed(250)
forward(10)
left(72)
forward(10)
right(144)
end_fill()