用python画派大星代码
时间: 2023-11-13 16:17:46 浏览: 674
要画派大星的话,可以使用turtle库来绘制。以下是一个简单的示例代码:
```python
import turtle
# 设置画布大小
turtle.setup(800, 600)
# 设置画笔大小和颜色
turtle.pensize(5)
turtle.pencolor("#00BFFF") # 派大星蓝
# 绘制身体
turtle.fillcolor("#FFD700") # 派大星黄
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 绘制眼睛
turtle.penup()
turtle.goto(-50, 150)
turtle.pendown()
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(25)
turtle.end_fill()
turtle.penup()
turtle.goto(-50, 165)
turtle.pendown()
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(50, 150)
turtle.pendown()
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(25)
turtle.end_fill()
turtle.penup()
turtle.goto(50, 165)
turtle.pendown()
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 绘制嘴巴
turtle.penup()
turtle.goto(-70, 100)
turtle.pendown()
turtle.right(60)
turtle.circle(-70, 120)
# 绘制胡须
turtle.penup()
turtle.goto(-70, 80)
turtle.pendown()
turtle.right(20)
turtle.forward(100)
turtle.penup()
turtle.goto(-70, 60)
turtle.pendown()
turtle.right(-40)
turtle.forward(100)
turtle.penup()
turtle.goto(-70, 40)
turtle.pendown()
turtle.right(-40)
turtle.forward(100)
# 隐藏画笔
turtle.hideturtle()
# 等待退出
turtle.done()
```
运行上述代码即可绘制出一个派大星的图形。
阅读全文