五星红旗

import turtle

设置画布

screen = turtle.Screen()
screen.setup(width=600, height=400)
screen.bgcolor("red")

创建画笔

pen = turtle.Turtle()
pen.speed(10)
pen.penup()

绘制五角星

def draw_star(x, y, radius, color):
pen.goto(x, y)
pen.setheading(0)
pen.pendown()
pen.begin_fill()
pen.fillcolor(color)
for _ in range(5):
pen.forward(radius)
pen.right(144)
pen.end_fill()
pen.penup()

绘制大五角星

draw_star(-250, 50, 100, "yellow")

绘制四颗小五角星

small_stars = [(-150, 120), (-120, 60), (-120, -20), (-150, -80)]
for star in small_stars:
draw_star(star[0], star[1], 30, "yellow")

隐藏画笔

pen.hideturtle()

结束

turtle.done()

posted @ 2025-03-02 15:23  cchb  阅读(16)  评论(0)    收藏  举报