Oct1a

Python用turtle模块绘制五星红旗

import turtle
t = turtle.Pen()
def Background(): #设置国旗背景
    t.color("red")
    t.begin_fill()
    for x in range (0,4):
        if x % 2 == 0:
            t.forward(300)
            t.left(90)
        else:
            t.forward(200)
            t.left(90)
    t.end_fill()
def yl_Star(size): #黄色五角星星
    t.begin_fill()
    for i in range(0,4):
        t.forward(int(size))
        t.left(216)
    t.end_fill()

def Big_Star_Move(x=-30,y=150,size=10): #移动画笔
    t.up()
    t.goto(x,y)
    t.color("yellow")
    t.forward(size)
    t.down()
def Five_Star(): #接着画五个星星
    Big_Star_Move(size=50)
    yl_Star(70)
    Big_Star_Move(135,155)
    yl_Star(28)
    Big_Star_Move(130,165)
    yl_Star(28)
    Big_Star_Move(110,83)
    yl_Star(28)
    Big_Star_Move(110,90)
    yl_Star(28)
    Big_Star_Move(0,0,0)
Background()
Five_Star()
turtle.mainloop()

本作品采用 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议 进行许可。