首页 > 其他 > 详细

五角星

时间:2018-03-20 17:20:55      阅读:201      评论:0      收藏:0      [点我收藏+]
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()

技术分享图片

 


  

五角星

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!