python设计花蕾
Posted yan-lin
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python设计花蕾相关的知识,希望对你有一定的参考价值。
#coding=gbk
import turtle
#设计树干
turtle.right(90)
turtle.pensize(2)
turtle.pencolor("black")
turtle.fillcolor("green")
turtle.begin_fill()
for _ in range(2):
turtle.forward(200)
turtle.left(90)
turtle.forward(20)
turtle.left(90)
turtle.end_fill()
turtle.left(90)
turtle.goto(10,0)
#设计花蕾
turtle.right(60)
turtle.fillcolor("red")
turtle.begin_fill()
for _ in range(6):
turtle.circle(50,180)
turtle.right(120)
turtle.end_fill()
#设计花芯
turtle.penup()
turtle.goto(10,20)
turtle.pendown()
turtle.left(60)
turtle.pensize(1)
turtle.color("black","violet")
turtle.begin_fill()
turtle.circle(80)
turtle.end_fill()
#设计叶子
turtle.penup()
turtle.goto(20,-110)
turtle.pendown()
turtle.fillcolor("green")
turtle.begin_fill()
turtle.left(10)
turtle.circle(200,60)
turtle.left(120)
turtle.circle(200,60)
turtle.end_fill()
turtle.penup()
turtle.goto(0,-110)
turtle.pendown()
turtle.right(140)
turtle.fillcolor("green")
turtle.begin_fill()
turtle.left(10)
turtle.circle(200,60)
turtle.left(120)
turtle.circle(200,60)
turtle.end_fill()
turtle.penup() #箭头连线断开
turtle.goto(-150,-260) #字体位置
turtle.color("yellow") #字体颜色
turtle.write("送你一朵小花花", font=(‘Arial‘, 30, ‘normal‘))
turtle.mainloop()
以上是关于python设计花蕾的主要内容,如果未能解决你的问题,请参考以下文章