python画图代码枫叶
时间: 2023-12-15 18:32:18 浏览: 171
以下是Python绘制枫叶的代码示例:
```python
import turtle
# 设置画笔
t = turtle.Turtle()
t.speed(0)
t.hideturtle()
# 绘制枫叶
def maple_leaf(x, y, size):
t.penup()
t.goto(x, y)
t.pendown()
t.setheading(0)
t.fillcolor('red')
t.begin_fill()
t.circle(size/2, 180)
t.circle(size/4, 180)
t.right(90)
t.forward(size*0.4)
t.left(120)
t.forward(size*0.4)
t.right(180)
t.circle(-size*0.8, 100)
t.right(180)
t.forward(size*0.4)
t.left(120)
t.forward(size*0.4)
t.right(90)
t.end_fill()
# 绘制多个枫叶
maple_leaf(-100, 0, 200)
maple_leaf(100, 0, 200)
maple_leaf(0, 100, 200)
maple_leaf(0, -100, 200)
# 显示绘图窗口
turtle.done()
```
阅读全文