turtle画五星红旗

import turtle

def goto(x,y):
    turtle.up();
    turtle.goto(x,y);
    turtle.down;

def drawxwjx(x):
    turtle.begin_fill()
    for i in range(5):
        turtle.forward(x)
        turtle.right(144)
    turtle.end_fill()

turtle.setup(600,400,0,0)
turtle.color("yellow")
turtle.bgcolor("red")

goto(-260,120)
turtle.begin_fill()
for i in range(5):
    turtle.forward(100)
    turtle.right(144)
turtle.end_fill()

for i in range(4):
    x = 1
    if i in [0,3]:
        x = 0
    goto(-120+x*45,180-i*45)
    turtle.left(15-i*15)
    drawxwjx(30)

turtle.hideturtle()

turtle.done()

  

原文地址:https://www.cnblogs.com/wlh0329/p/8609978.html