码迷,mamicode.com
首页 > 其他好文 > 详细

五角星

时间:2018-03-20 18:19:07      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:yellow   goto   图片   raw   port   tle   class   color   bubuko   

import  turtle

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


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

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

mygoto(-250, 95)
draw(100)

for i in  range(4):
    x=1

    if i in [0, 3]:
        x=0
    mygoto(-135+x*30, 155-i*45)  # goto
    turtle.left(25-i*15)  # 转角度
    draw(30)  # draw


turtle.hideturtle()

turtle.done()

技术分享图片

 


  

五角星

标签:yellow   goto   图片   raw   port   tle   class   color   bubuko   

原文地址:https://www.cnblogs.com/qq412158152/p/8610292.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!