Python调用turtle库画警犬
时间: 2023-06-11 17:04:59 浏览: 100
好的,以下是使用Python调用turtle库画警犬的代码示例:
```python
import turtle
# 绘制身体
turtle.penup()
turtle.goto(-50, 0)
turtle.pendown()
turtle.color('brown')
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
# 绘制腿
turtle.penup()
turtle.goto(-30, -60)
turtle.pendown()
turtle.color('brown')
turtle.begin_fill()
turtle.forward(60)
turtle.right(90)
turtle.forward(20)
turtle.right(90)
turtle.forward(60)
turtle.right(90)
turtle.forward(20)
turtle.end_fill()
# 绘制头部
turtle.penup()
turtle.goto(20, 0)
turtle.pendown()
turtle.color('brown')
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
# 绘制耳朵
turtle.penup()
turtle.goto(40, 50)
turtle.pendown()
turtle.color('brown')
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(20, 50)
turtle.pendown()
turtle.color('brown')
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 绘制眼睛
turtle.penup()
turtle.goto(10, 10)
turtle.pendown()
turtle.color('white')
turtle.begin_fill()
turtle.circle(5)
turtle.end_fill()
turtle.penup()
turtle.goto(30, 10)
turtle.pendown()
turtle.color('white')
turtle.begin_fill()
turtle.circle(5)
turtle.end_fill()
turtle.penup()
turtle.goto(13, 10)
turtle.pendown()
turtle.color('black')
turtle.begin_fill()
turtle.circle(2)
turtle.end_fill()
turtle.penup()
turtle.goto(33, 10)
turtle.pendown()
turtle.color('black')
turtle.begin_fill()
turtle.circle(2)
turtle.end_fill()
# 绘制尾巴
turtle.penup()
turtle.goto(-90, 0)
turtle.pendown()
turtle.color('brown')
turtle.begin_fill()
turtle.circle(10)
turtle.right(90)
turtle.forward(20)
turtle.right(90)
turtle.circle(10)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
turtle.done()
```
以上代码可以绘制一个警犬的图形。希望对你有所帮助!
阅读全文