给出用海龟绘图画柯南的代码
时间: 2024-05-02 22:01:37 浏览: 108
以下是使用Python的turtle库画柯南的代码:
```python
import turtle
# 设置画布大小和背景颜色
turtle.setup(800, 600)
turtle.bgcolor("#F5DEB3")
# 画脸部轮廓
turtle.pensize(4)
turtle.penup()
turtle.goto(-50, 100)
turtle.pendown()
turtle.circle(80)
# 画左眼
turtle.penup()
turtle.goto(-30, 170)
turtle.pendown()
turtle.fillcolor("#FFF")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.fillcolor("#000")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 画右眼
turtle.penup()
turtle.goto(30, 170)
turtle.pendown()
turtle.fillcolor("#FFF")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.fillcolor("#000")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 画嘴巴
turtle.penup()
turtle.goto(-40, 80)
turtle.pendown()
turtle.fillcolor("#F5DEB3")
turtle.begin_fill()
turtle.left(45)
turtle.forward(50)
turtle.circle(30, 180)
turtle.forward(50)
turtle.end_fill()
# 画发型
turtle.penup()
turtle.goto(-80, 200)
turtle.pendown()
turtle.pensize(6)
turtle.right(30)
turtle.forward(60)
turtle.left(60)
turtle.forward(60)
turtle.right(60)
turtle.forward(60)
# 隐藏海龟
turtle.hideturtle()
turtle.done()
```
运行以上代码,即可绘制出柯南的头像。
阅读全文