python画小猫咪代码
时间: 2023-07-03 15:14:07 浏览: 190
这里是一个使用Python绘制小猫咪的示例代码:
```python
import turtle
# 绘制猫脸
def draw_face():
turtle.pensize(5)
turtle.penup()
turtle.goto(0, -100)
turtle.pendown()
turtle.circle(100)
# 绘制猫耳朵
def draw_ears():
turtle.fillcolor("pink")
turtle.penup()
turtle.goto(-70, 70)
turtle.pendown()
turtle.begin_fill()
turtle.right(45)
turtle.forward(50)
turtle.right(135)
turtle.forward(100)
turtle.right(135)
turtle.forward(50)
turtle.end_fill()
turtle.fillcolor("pink")
turtle.penup()
turtle.goto(70, 70)
turtle.pendown()
turtle.begin_fill()
turtle.left(45)
turtle.forward(50)
turtle.left(135)
turtle.forward(100)
turtle.left(135)
turtle.forward(50)
turtle.end_fill()
# 绘制猫眼睛
def draw_eyes():
turtle.fillcolor("white")
turtle.penup()
turtle.goto(-40, 20)
turtle.pendown()
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.fillcolor("black")
turtle.penup()
turtle.goto(-40, 25)
turtle.pendown()
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
turtle.fillcolor("white")
turtle.penup()
turtle.goto(40, 20)
turtle.pendown()
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.fillcolor("black")
turtle.penup()
turtle.goto(40, 25)
turtle.pendown()
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 绘制猫嘴巴
def draw_mouth():
turtle.penup()
turtle.goto(-30, -20)
turtle.pendown()
turtle.right(45)
turtle.circle(30, 90)
# 绘制猫身体
def draw_body():
turtle.fillcolor("gray")
turtle.penup()
turtle.goto(0, -200)
turtle.pendown()
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 绘制猫爪子
def draw_paws():
turtle.fillcolor("pink")
turtle.penup()
turtle.goto(-50, -150)
turtle.pendown()
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.fillcolor("pink")
turtle.penup()
turtle.goto(50, -150)
turtle.pendown()
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 绘制猫尾巴
def draw_tail():
turtle.penup()
turtle.goto(80, -200)
turtle.pendown()
turtle.right(45)
turtle.circle(50, 90)
# 主函数
def main():
turtle.speed(0)
draw_face()
draw_ears()
draw_eyes()
draw_mouth()
draw_body()
draw_paws()
draw_tail()
turtle.done()
if __name__ == "__main__":
main()
```
运行代码,就可以绘制出一个可爱的小猫咪了!