这篇文章主要介绍了怎么用python画六角星,具有一定借鉴价值,需要的朋友可以参考下。希望大家阅读完这篇文章后大有收获,下面让小编带着大家一起了解一下。
import turtle as t
t.penup()
t.fd(-200)
t.write("一朵小花\n", align="right", font=("楷体", 16, "bold"))
def draw_leaf():
for i in range(2):
for j in range(15):
t.forward(5)
t.right(6)
t.right(90)
t.goto(0,-150)
t.left(90)
t.down()
t.forward(50)
t.fillcolor("green")
t.begin_fill()
draw_leaf()
t.end_fill()
t.forward(50)
t.right(270)
t.fillcolor("green")
t.begin_fill()
draw_leaf()
t.end_fill()
t.right(90)
t.forward(130)
t.fillcolor("red")
t.begin_fill()
for i in range(6):
draw_leaf()
t.right(60)
t.end_fill()
t.done()