python画图人物
时间: 2023-11-20 10:58:15 浏览: 30
以下是使用Python绘制人物的示例代码:
```python
import turtle
# 设置画笔
t = turtle.Pen()
t.pensize(3)
t.speed(10)
# 绘制头部
t.fillcolor('yellow')
t.begin_fill()
t.circle(100)
t.end_fill()
# 绘制眼睛
t.penup()
t.goto(-40, 120)
t.pendown()
t.fillcolor('white')
t.begin_fill()
t.circle(20)
t.end_fill()
t.penup()
t.goto(-40, 130)
t.pendown()
t.fillcolor('black')
t.begin_fill()
t.circle(10)
t.end_fill()
t.penup()
t.goto(40, 120)
t.pendown()
t.fillcolor('white')
t.begin_fill()
t.circle(20)
t.end_fill()
t.penup()
t.goto(40, 130)
t.pendown()
t.fillcolor('black')
t.begin_fill()
t.circle(10)
t.end_fill()
# 绘制嘴巴
t.penup()
t.goto(-60, 80)
t.pendown()
t.right(60)
t.circle(80, 120)
# 绘制身体
t.penup()
t.goto(-150, -100)
t.pendown()
t.fillcolor('blue')
t.begin_fill()
t.forward(300)
t.right(90)
t.circle(50, 180)
t.right(90)
t.forward(300)
t.end_fill()
# 绘制手臂
t.penup()
t.goto(-150, -100)
t.pendown()
t.fillcolor('white')
t.begin_fill()
t.right(45)
t.forward(100)
t.right(90)
t.forward(50)
t.right(90)
t.forward(50)
t.right(90)
t.forward(50)
t.right(90)
t.forward(50)
t.right(90)
t.forward(50)
t.right(90)
t.forward(50)
t.right(90)
t.forward(100)
t.right(135)
t.forward(70)
t.end_fill()
t.penup()
t.goto(150, -100)
t.pendown()
t.fillcolor('white')
t.begin_fill()
t.right(180)
t.forward(100)
t.right(90)
t.forward(50)
t.right(90)
t.forward(50)
t.right(90)
t.forward(50)
t.right(90)
t.forward(50)
t.right(90)
t.forward(50)
t.right(90)
t.forward(50)
t.right(90)
t.forward(100)
t.right(135)
t.forward(70)
t.end_fill()
# 绘制脚
t.penup()
t.goto(-100, -250)
t.pendown()
t.fillcolor('white')
t.begin_fill()
t.right(45)
t.forward(50)
t.right(90)
t.forward(50)
t.right(90)
t.forward(50)
t.right(90)
t.forward(50)
t.right(135)
t.forward(70)
t.end_fill()
t.penup()
t.goto(100, -250)
t.pendown()
t.fillcolor('white')
t.begin_fill()
t.right(180)
t.forward(50)
t.right(90)
t.forward(50)
t.right(90)
t.forward(50)
t.right(90)
t.forward(50)
t.right(135)
t.forward(70)
t.end_fill()
# 隐藏画笔
t.hideturtle()
# 显示绘图窗口
turtle.done()
```