python画端午主题的画
时间: 2023-07-01 14:20:13 浏览: 103
好的,我可以为您提供一个简单的Python代码示例,用于绘制端午主题的画:
```python
import turtle
# 设置画布大小和背景色
turtle.setup(800, 600)
turtle.bgcolor("white")
# 绘制端午节主题图案
# 绘制五彩丝线
turtle.pensize(10)
turtle.speed(10)
colors = ["red", "orange", "yellow", "green", "blue", "purple"]
for i in range(6):
turtle.color(colors[i])
turtle.penup()
turtle.goto(-200 + i*80, 0)
turtle.pendown()
turtle.circle(50)
# 绘制粽子
turtle.color("brown")
turtle.begin_fill()
turtle.penup()
turtle.goto(-100, 100)
turtle.pendown()
turtle.setheading(60)
turtle.forward(100)
turtle.setheading(0)
turtle.forward(80)
turtle.setheading(-60)
turtle.forward(100)
turtle.setheading(180)
turtle.forward(80)
turtle.end_fill()
# 绘制香叶
turtle.color("green")
turtle.penup()
turtle.goto(-80, 150)
turtle.pendown()
turtle.setheading(60)
turtle.forward(20)
turtle.setheading(0)
turtle.forward(20)
turtle.setheading(-60)
turtle.forward(20)
# 绘制艾叶
turtle.color("lightgreen")
turtle.penup()
turtle.goto(-120, 150)
turtle.pendown()
turtle.setheading(60)
turtle.forward(20)
turtle.setheading(0)
turtle.forward(20)
turtle.setheading(-60)
turtle.forward(20)
# 绘制端午节的字样
turtle.color("black")
turtle.penup()
turtle.goto(0, -200)
turtle.pendown()
turtle.write("端午节快乐!", align="center", font=("Arial", 30, "normal"))
# 隐藏画笔
turtle.hideturtle()
# 点击关闭窗口
turtle.done()
```
您可以根据您的需求自定义画布大小、颜色和图案。希望对您有所帮助!
阅读全文