python turtle绘奥特曼
时间: 2023-09-26 20:07:54 浏览: 111
下面是使用 Python turtle 绘制奥特曼的代码:
```python
import turtle
# 设置画布大小
turtle.setup(800, 600)
# 创建画笔
pen = turtle.Pen()
# 奥特曼头部
pen.penup()
pen.goto(0, 200)
pen.pendown()
pen.begin_fill()
pen.fillcolor('red')
pen.circle(100)
pen.end_fill()
# 奥特曼眼睛
pen.penup()
pen.goto(-50, 250)
pen.pendown()
pen.begin_fill()
pen.fillcolor('white')
pen.circle(30)
pen.end_fill()
pen.penup()
pen.goto(50, 250)
pen.pendown()
pen.begin_fill()
pen.fillcolor('white')
pen.circle(30)
pen.end_fill()
# 奥特曼眼珠
pen.penup()
pen.goto(-40, 270)
pen.pendown()
pen.begin_fill()
pen.fillcolor('black')
pen.circle(10)
pen.end_fill()
pen.penup()
pen.goto(60, 270)
pen.pendown()
pen.begin_fill()
pen.fillcolor('black')
pen.circle(10)
pen.end_fill()
# 奥特曼鼻子
pen.penup()
pen.goto(0, 200)
pen.pendown()
pen.begin_fill()
pen.fillcolor('black')
pen.circle(10)
pen.end_fill()
# 奥特曼嘴巴
pen.penup()
pen.goto(-60, 180)
pen.pendown()
pen.pensize(15)
pen.right(45)
pen.forward(100)
# 奥特曼身体
pen.penup()
pen.goto(0, 0)
pen.pendown()
pen.begin_fill()
pen.fillcolor('red')
pen.right(135)
pen.forward(200)
pen.right(45)
pen.circle(100, 180)
pen.right(45)
pen.forward(200)
pen.end_fill()
# 奥特曼腰带
pen.penup()
pen.goto(0, 0)
pen.pendown()
pen.begin_fill()
pen.fillcolor('silver')
pen.right(135)
pen.forward(150)
pen.right(45)
pen.forward(100)
pen.right(45)
pen.forward(150)
pen.right(45)
pen.forward(100)
pen.end_fill()
# 奥特曼腰带上的字
pen.penup()
pen.goto(0, -50)
pen.pendown()
pen.write('ULTRAMAN', align='center', font=('Arial', 20, 'bold'))
# 完成绘制
turtle.done()
```
运行代码后,即可在窗口中看到绘制出的奥特曼。
阅读全文