1. 程式人生 > >python畫國旗

python畫國旗

begin left fill brush color for raw forward img

import turtle

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


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

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

mygoto(-260,130)
drawwwu(100)


for i in range(4):
    x=1
    if i in [0, 3]:
        x=0
    mygoto(-125+x*30,160-i*30)
    turtle.left(15-i*17)
    drawwwu(30)

mygoto(0, 0)
turtle.hideturtle()
turtle.done()

  技術分享圖片

python畫國旗