用turtle写封仁和
时间: 2024-03-16 22:48:13 浏览: 117
好的,以下是使用 Python 的 turtle 库绘制封仁和的示例代码:
```python
import turtle
# 设置画笔速度和画布大小
turtle.speed(2)
turtle.setup(800, 800)
# 绘制圆形
turtle.penup()
turtle.goto(0, -200)
turtle.pendown()
turtle.pensize(5)
turtle.fillcolor("#FFC0CB")
turtle.begin_fill()
turtle.circle(200)
turtle.end_fill()
# 绘制两只眼睛
turtle.penup()
turtle.goto(-80, 100)
turtle.pendown()
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
turtle.penup()
turtle.goto(80, 100)
turtle.pendown()
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
# 绘制眼珠子
turtle.penup()
turtle.goto(-60, 120)
turtle.pendown()
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(60, 120)
turtle.pendown()
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 绘制嘴巴
turtle.penup()
turtle.goto(-100, 0)
turtle.pendown()
turtle.pensize(10)
turtle.right(45)
turtle.circle(100, 90)
turtle.penup()
turtle.goto(-100, 0)
turtle.pendown()
turtle.left(90)
turtle.circle(-100, 90)
# 绘制左耳朵
turtle.penup()
turtle.goto(-200, 150)
turtle.pendown()
turtle.fillcolor("#FFC0CB")
turtle.begin_fill()
turtle.right(45)
turtle.forward(100)
turtle.left(135)
turtle.circle(70, -80)
turtle.left(45)
turtle.forward(80)
turtle.end_fill()
# 绘制右耳朵
turtle.penup()
turtle.goto(200, 150)
turtle.pendown()
turtle.fillcolor("#FFC0CB")
turtle.begin_fill()
turtle.right(135)
turtle.forward(100)
turtle.left(135)
turtle.circle(-70, -80)
turtle.left(45)
turtle.forward(80)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
# 显示绘图窗口
turtle.done()
```
上述代码可以在 Python 环境中直接运行,即可绘制出一个简单的粉色封仁和图案。您可以根据需要进行调整,例如更改颜色、大小、位置等参数,以获得更满意的效果。
阅读全文