Python画小灰灰
时间: 2023-12-14 18:33:37 浏览: 129
一个使图像变灰的小例子
以下是Python画小灰灰的代码示例:
```python
import turtle
# 画身体
def body():
turtle.penup()
turtle.goto(-30, -30)
turtle.pendown()
turtle.begin_fill()
turtle.color('grey')
turtle.circle(50)
turtle.end_fill()
# 画头发
def hair():
turtle.penup()
turtle.goto(-10, 60)
turtle.pendown()
turtle.pensize(5)
turtle.color('black')
turtle.right(30)
turtle.forward(20)
turtle.left(60)
turtle.forward(20)
turtle.right(30)
turtle.backward(20)
turtle.right(30)
turtle.forward(20)
turtle.left(60)
turtle.forward(20)
turtle.right(30)
turtle.backward(20)
# 画耳朵
def ears():
turtle.penup()
turtle.goto(-60, 20)
turtle.pendown()
turtle.begin_fill()
turtle.color('grey')
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(20, 20)
turtle.pendown()
turtle.begin_fill()
turtle.color('grey')
turtle.circle(10)
turtle.end_fill()
# 画脸
def face():
turtle.penup()
turtle.goto(-20, 20)
turtle.pendown()
turtle.begin_fill()
turtle.color('white')
turtle.circle(20)
turtle.end_fill()
# 画衣服
def cloth():
turtle.penup()
turtle.goto(-30, -30)
turtle.pendown()
turtle.begin_fill()
turtle.color('red')
turtle.circle(30)
turtle.end_fill()
# 画手
def hands():
turtle.penup()
turtle.goto(-60, -30)
turtle.pendown()
turtle.begin_fill()
turtle.color('grey')
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(30, -30)
turtle.pendown()
turtle.begin_fill()
turtle.color('grey')
turtle.circle(10)
turtle.end_fill()
# 画腿
def legs():
turtle.penup()
turtle.goto(-20, -80)
turtle.pendown()
turtle.begin_fill()
turtle.color('black')
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(10, -80)
turtle.pendown()
turtle.begin_fill()
turtle.color('black')
turtle.circle(10)
turtle.end_fill()
# 调用各个方法,画出小灰灰
body()
hair()
ears()
face()
cloth()
hands()
legs()
turtle.done()
```
阅读全文