使用python画叮当猫
时间: 2024-01-10 14:20:44 浏览: 28
以下是使用Python画叮当猫的示例代码:
```python
import turtle
# 设置画布大小和背景颜色
turtle.setup(800, 600)
turtle.bgcolor("white")
# 设置画笔颜色和粗细
turtle.pensize(3)
turtle.pencolor("black")
# 画猫头
turtle.penup()
turtle.goto(-50, 100)
turtle.pendown()
turtle.circle(100)
# 画眼睛
turtle.penup()
turtle.goto(-30, 160)
turtle.pendown()
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(-70, 160)
turtle.pendown()
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 画眼珠
turtle.penup()
turtle.goto(-60, 170)
turtle.pendown()
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(5)
turtle.end_fill()
turtle.penup()
turtle.goto(-40, 170)
turtle.pendown()
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(5)
turtle.end_fill()
# 画鼻子
turtle.penup()
turtle.goto(-50, 140)
turtle.pendown()
turtle.setheading(-30)
turtle.fillcolor("red")
turtle.begin_fill()
turtle.circle(15, 180)
turtle.end_fill()
# 画嘴巴
turtle.penup()
turtle.goto(-50, 140)
turtle.pendown()
turtle.setheading(-60)
turtle.circle(30, 120)
turtle.penup()
turtle.goto(-50, 140)
turtle.pendown()
turtle.setheading(60)
turtle.circle(-30, 120)
# 画胡须
turtle.penup()
turtle.goto(-70, 110)
turtle.pendown()
turtle.setheading(40)
turtle.circle(-80, 80)
turtle.penup()
turtle.goto(-70, 110)
turtle.pendown()
turtle.setheading(140)
turtle.circle(80, 80)
turtle.penup()
turtle.goto(-70, 110)
turtle.pendown()
turtle.setheading(100)
turtle.circle(-80, 80)
turtle.penup()
turtle.goto(-70, 110)
turtle.pendown()
turtle.setheading(-40)
turtle.circle(80, 80)
# 画身体
turtle.penup()
turtle.goto(-50, 100)
turtle.pendown()
turtle.setheading(-30)
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(200, 180)
turtle.circle(100, 180)
turtle.left(90)
turtle.forward(200)
turtle.end_fill()
# 画脚
turtle.penup()
turtle.goto(-150, -60)
turtle.pendown()
turtle.setheading(-90)
turtle.fillcolor("white")
turtle.begin_fill()
turtle.forward(30)
turtle.right(45)
turtle.circle(80, -90)
turtle.right(90)
turtle.forward(30)
turtle.end_fill()
turtle.penup()
turtle.goto(50, -60)
turtle.pendown()
turtle.setheading(-90)
turtle.fillcolor("white")
turtle.begin_fill()
turtle.forward(30)
turtle.left(45)
turtle.circle(-80, -90)
turtle.left(90)
turtle.forward(30)
turtle.end_fill()
# 画尾巴
turtle.penup()
turtle.goto(20, -200)
turtle.pendown()
turtle.setheading(0)
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(20, 180)
turtle.circle(10, 180)
turtle.left(90)
turtle.forward(20)
turtle.end_fill()
# 画落款
turtle.penup()
turtle.goto(-200, -250)
turtle.pendown()
turtle.write("自定义的精美的落款", align="center", font=("微软雅黑", 16, "bold"))
# 隐藏画笔
turtle.hideturtle()
# 点击关闭窗口退出程序
turtle.exitonclick()
```
相关推荐
![py](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)