Python绘制五星红旗

# -*- coding: UTF-8 -*-
from turtle import *

def mygoto(x,y):
    up()
    goto(x,y)
    down()

def draw(z):
    begin_fill()
    for i in range(5):
        forward(z)
        right(144)
    end_fill()

setup(700, 500, 0, 0)
color("yellow")
bgcolor("red")
fillcolor("yellow")
hideturtle()

mygoto(-300,150)
draw(100)

for i in range(4):
    x=1;
    if i in [0,3]:
        x=0;
    mygoto(-210+x*50,205-i*50)
    left(0-i*10)
    draw(30)
mygoto(0,0)
hideturtle()

done()

运行结果:

 

posted @ 2018-03-19 10:35  112李立建  阅读(575)  评论(0编辑  收藏  举报