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

turtle绘制花朵

时间:2018-04-11 23:03:50      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:range   style   this   code   down   图片   class   info   img   

import turtle
angles=(0,30,60,90,120,150,180,210,240,270,300,330)
colors=("blue","green","pink","purple","black","red","yellow","grey","white","beige","ivory","thistle")
angles2=(0,180)
def huaban(ang,color):
    turtle.pensize(2)
    turtle.color("black",color)  
    turtle.seth(ang)
    turtle.right(15)
    turtle.pendown()
    turtle.begin_fill()
    turtle.circle(250,30)
    turtle.left(150)
    turtle.circle(250,30)
    turtle.end_fill()
    turtle.penup()
def yezi(ang):
    turtle.pensize(2)
    turtle.color("black","green")  
    turtle.seth(ang)
    turtle.right(15)
    turtle.pendown()
    turtle.begin_fill()
    turtle.circle(120,60)
    turtle.left(120)
    turtle.circle(120,60)
    turtle.end_fill()
    turtle.penup()
def main():
    turtle.setup(500,800)
    turtle.penup()
    turtle.seth(90)
    turtle.fd(200)
    turtle.speed(0)
    for i in range(12):
        huaban(angles[i],colors[i])
    turtle.seth(270)
    turtle.pendown()
    turtle.fd(200)
    for j in range(2):
        yezi(angles2[j])
    turtle.seth(270)
    turtle.pendown()
    turtle.fd(200)
        
main()

技术分享图片

turtle绘制花朵

标签:range   style   this   code   down   图片   class   info   img   

原文地址:https://www.cnblogs.com/knightwen/p/8799131.html

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