用Python的turtle库画派大星
时间: 2023-06-17 22:07:14 浏览: 369
好的,以下是用Python的turtle库画派大星的代码:
```python
import turtle
# 定义画布大小和背景颜色
turtle.setup(800, 600)
turtle.bgcolor("lightblue")
# 定义画笔属性
turtle.pensize(5)
turtle.pencolor("black")
# 画派大星的头部
turtle.fillcolor("#FCE94F")
turtle.begin_fill()
turtle.circle(150)
turtle.end_fill()
# 画派大星的眼睛
turtle.penup()
turtle.goto(-50, 200)
turtle.pendown()
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
turtle.penup()
turtle.goto(50, 200)
turtle.pendown()
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
# 画派大星的瞳孔
turtle.penup()
turtle.goto(-50, 220)
turtle.pendown()
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(25)
turtle.end_fill()
turtle.penup()
turtle.goto(50, 220)
turtle.pendown()
turtle.begin_fill()
turtle.circle(25)
turtle.end_fill()
# 画派大星的鼻子
turtle.penup()
turtle.goto(0, 120)
turtle.pendown()
turtle.fillcolor("red")
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
# 画派大星的嘴巴
turtle.penup()
turtle.goto(-100, 20)
turtle.pendown()
turtle.right(45)
turtle.circle(150, 90)
# 画派大星的牙齿
turtle.penup()
turtle.goto(-25, 20)
turtle.pendown()
turtle.fillcolor("white")
turtle.begin_fill()
turtle.left(135)
turtle.forward(50)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(50)
turtle.end_fill()
# 完成画派大星
turtle.hideturtle()
turtle.done()
```
运行代码后,会弹出一个窗口,里面画出了派大星的形象。你可以调整画笔属性和坐标值,让派大星的形象更符合你的想象。