用python turtle画人物素描
时间: 2023-07-12 15:46:46 浏览: 144
好的,我可以教你用Python Turtle库画人物素描。首先,我们需要导入Turtle库:
```python
import turtle
```
然后,我们需要设置画布的大小和背景颜色:
```python
turtle.setup(800, 800)
turtle.bgcolor('white')
```
接着,我们需要定义一个函数来画人物素描:
```python
def draw_sketch():
# 画头部
turtle.pensize(2)
turtle.penup()
turtle.goto(0, 100)
turtle.pendown()
turtle.circle(50)
# 画眼睛
turtle.penup()
turtle.goto(-20, 120)
turtle.pendown()
turtle.circle(10)
turtle.penup()
turtle.goto(20, 120)
turtle.pendown()
turtle.circle(10)
# 画鼻子
turtle.penup()
turtle.goto(0, 100)
turtle.pendown()
turtle.right(90)
turtle.forward(20)
turtle.left(135)
turtle.forward(30)
turtle.right(135)
turtle.forward(30)
# 画嘴巴
turtle.penup()
turtle.goto(-25, 80)
turtle.pendown()
turtle.left(90)
turtle.circle(25, 180)
# 画身体
turtle.penup()
turtle.goto(0, 50)
turtle.pendown()
turtle.forward(100)
turtle.right(90)
turtle.forward(150)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(150)
# 画手臂
turtle.penup()
turtle.goto(-100, 50)
turtle.pendown()
turtle.right(45)
turtle.forward(75)
turtle.right(45)
turtle.forward(50)
turtle.right(45)
turtle.forward(75)
turtle.penup()
turtle.goto(100, 50)
turtle.pendown()
turtle.left(45)
turtle.forward(75)
turtle.left(45)
turtle.forward(50)
turtle.left(45)
turtle.forward(75)
# 画腿
turtle.penup()
turtle.goto(-50, -100)
turtle.pendown()
turtle.right(45)
turtle.forward(100)
turtle.right(45)
turtle.forward(50)
turtle.right(45)
turtle.forward(100)
turtle.penup()
turtle.goto(50, -100)
turtle.pendown()
turtle.left(45)
turtle.forward(100)
turtle.left(45)
turtle.forward(50)
turtle.left(45)
turtle.forward(100)
# 结束
turtle.hideturtle()
```
最后,我们只需要调用这个函数就可以画出人物素描了:
```python
draw_sketch()
```
完整代码如下:
```python
import turtle
def draw_sketch():
turtle.setup(800, 800)
turtle.bgcolor('white')
turtle.pensize(2)
turtle.penup()
turtle.goto(0, 100)
turtle.pendown()
turtle.circle(50)
turtle.penup()
turtle.goto(-20, 120)
turtle.pendown()
turtle.circle(10)
turtle.penup()
turtle.goto(20, 120)
turtle.pendown()
turtle.circle(10)
turtle.penup()
turtle.goto(0, 100)
turtle.pendown()
turtle.right(90)
turtle.forward(20)
turtle.left(135)
turtle.forward(30)
turtle.right(135)
turtle.forward(30)
turtle.penup()
turtle.goto(-25, 80)
turtle.pendown()
turtle.left(90)
turtle.circle(25, 180)
turtle.penup()
turtle.goto(0, 50)
turtle.pendown()
turtle.forward(100)
turtle.right(90)
turtle.forward(150)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(150)
turtle.penup()
turtle.goto(-100, 50)
turtle.pendown()
turtle.right(45)
turtle.forward(75)
turtle.right(45)
turtle.forward(50)
turtle.right(45)
turtle.forward(75)
turtle.penup()
turtle.goto(100, 50)
turtle.pendown()
turtle.left(45)
turtle.forward(75)
turtle.left(45)
turtle.forward(50)
turtle.left(45)
turtle.forward(75)
turtle.penup()
turtle.goto(-50, -100)
turtle.pendown()
turtle.right(45)
turtle.forward(100)
turtle.right(45)
turtle.forward(50)
turtle.right(45)
turtle.forward(100)
turtle.penup()
turtle.goto(50, -100)
turtle.pendown()
turtle.left(45)
turtle.forward(100)
turtle.left(45)
turtle.forward(50)
turtle.left(45)
turtle.forward(100)
turtle.hideturtle()
draw_sketch()
```
运行代码,就可以看到画出的人物素描了。
阅读全文