python turtle画猪猪侠
时间: 2023-09-07 15:15:06 浏览: 1979
好的,以下是画猪猪侠的代码:
```python
import turtle
# 设置画笔
pen = turtle.Turtle()
pen.speed(0)
pen.color('black')
# 画猪猪侠的头部
pen.fillcolor('pink')
pen.begin_fill()
pen.circle(100)
pen.end_fill()
# 画猪猪侠的眼睛
pen.penup()
pen.goto(-40, 120)
pen.pendown()
pen.fillcolor('white')
pen.begin_fill()
pen.circle(20)
pen.end_fill()
pen.penup()
pen.goto(-30, 130)
pen.pendown()
pen.fillcolor('black')
pen.begin_fill()
pen.circle(10)
pen.end_fill()
pen.penup()
pen.goto(40, 120)
pen.pendown()
pen.fillcolor('white')
pen.begin_fill()
pen.circle(20)
pen.end_fill()
pen.penup()
pen.goto(50, 130)
pen.pendown()
pen.fillcolor('black')
pen.begin_fill()
pen.circle(10)
pen.end_fill()
# 画猪猪侠的鼻子
pen.penup()
pen.goto(0, 100)
pen.pendown()
pen.fillcolor('black')
pen.begin_fill()
pen.circle(10)
pen.end_fill()
# 画猪猪侠的嘴巴
pen.penup()
pen.goto(-60, 80)
pen.pendown()
pen.circle(60, 30)
pen.circle(60, 120)
pen.circle(60, 30)
# 画猪猪侠的耳朵
pen.penup()
pen.goto(-100, 170)
pen.pendown()
pen.fillcolor('pink')
pen.begin_fill()
pen.circle(40)
pen.end_fill()
pen.penup()
pen.goto(-90, 190)
pen.pendown()
pen.fillcolor('black')
pen.begin_fill()
pen.circle(20)
pen.end_fill()
pen.penup()
pen.goto(100, 170)
pen.pendown()
pen.fillcolor('pink')
pen.begin_fill()
pen.circle(40)
pen.end_fill()
pen.penup()
pen.goto(90, 190)
pen.pendown()
pen.fillcolor('black')
pen.begin_fill()
pen.circle(20)
pen.end_fill()
# 画猪猪侠的身体
pen.penup()
pen.goto(-60, 0)
pen.pendown()
pen.fillcolor('pink')
pen.begin_fill()
pen.circle(100, 180)
pen.goto(60, -80)
pen.circle(20, 180)
pen.goto(-60, -180)
pen.circle(100, 180)
pen.goto(-60, 0)
pen.end_fill()
# 画猪猪侠的手臂
pen.penup()
pen.goto(-120, -60)
pen.pendown()
pen.fillcolor('pink')
pen.begin_fill()
pen.circle(40)
pen.end_fill()
pen.penup()
pen.goto(120, -60)
pen.pendown()
pen.fillcolor('pink')
pen.begin_fill()
pen.circle(40)
pen.end_fill()
# 画猪猪侠的脚
pen.penup()
pen.goto(-60, -180)
pen.pendown()
pen.fillcolor('black')
pen.begin_fill()
pen.circle(30, 180)
pen.goto(-90, -240)
pen.goto(-60, -240)
pen.goto(-60, -180)
pen.end_fill()
pen.penup()
pen.goto(60, -180)
pen.pendown()
pen.fillcolor('black')
pen.begin_fill()
pen.circle(30, 180)
pen.goto(90, -240)
pen.goto(60, -240)
pen.goto(60, -180)
pen.end_fill()
# 完成画图
turtle.done()
```
运行代码后,就会看到猪猪侠的图像啦!
阅读全文