不废话,直接上代码。(如果喜欢,欢迎关注下)
import turtle
# 画布
canvas = turtle.Screen()
canvas.setup(1000, 800)
canvas.title("中国国旗")
# 画笔
pen = turtle.Turtle()
pen.speed(10)
pen.hideturtle()
# 红色矩形
pen.penup()
pen.goto(-200, 100)
pen.pendown()
pen.begin_fill()
pen.color("red")
for i in range(2):
pen.forward(400)
pen.right(90)
pen.forward(100)
pen.right(90)
pen.end_fill()
# 大五角星
pen.penup()
pen.goto(-150, 70)
pen.pendown()
pen.begin_fill()
pen.color("yellow")
for i in range(5):
pen.forward(60)
pen.right(144)
pen.end_fill()
# 四个小五角星
pen.penup()
pen.goto(-90, 90)
pen.pendown()
pen.begin_fill()
pen.color("yellow")
for i in range(5):
pen.forward(20)
pen.right(144)
pen.end_fill()
pen.penup()
pen.goto(-60, 70)
pen.pendown()
pen.begin_fill()
pen.color("yellow")
for i in range(5):
pen.forward(20)
pen.right(144)
pen.end_fill()
pen.penup()
pen.goto(-60, 40)
pen.pendown()
pen.begin_fill()
pen.color("yellow")
for i in range(5):
pen.forward(20)
pen.right(144)
pen.end_fill()
pen.penup()
pen.goto(-90, 20)
pen.pendown()
pen.begin_fill()
pen.color("yellow")
for i in range(5):
pen.forward(20)
pen.right(144)
pen.end_fill()
turtle.done()