turtle绘制奥特曼代码
时间: 2023-05-29 13:04:31 浏览: 163
以下是使用Python的turtle模块绘制奥特曼的代码:
```
import turtle
# 设置画布大小和背景颜色
turtle.setup(800, 600)
turtle.bgcolor('black')
# 定义奥特曼身体颜色和眼睛颜色
body_color = '#E30613'
eye_color = '#FFFFFF'
# 绘制奥特曼头部
turtle.penup()
turtle.goto(0, 100)
turtle.pendown()
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 绘制奥特曼身体
turtle.penup()
turtle.goto(0, 0)
turtle.pendown()
turtle.begin_fill()
turtle.setheading(270)
turtle.circle(50, 180)
turtle.color(body_color)
turtle.goto(0, 0)
turtle.end_fill()
# 绘制奥特曼眼睛
turtle.penup()
turtle.goto(-30, 130)
turtle.pendown()
turtle.color(eye_color)
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(30, 130)
turtle.pendown()
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 绘制奥特曼嘴巴
turtle.penup()
turtle.goto(-60, 70)
turtle.pendown()
turtle.color('#000000')
turtle.setheading(-30)
turtle.circle(70, 60)
turtle.penup()
turtle.setheading(180)
turtle.goto(60, 70)
turtle.pendown()
turtle.setheading(210)
turtle.circle(-70, 60)
# 绘制奥特曼手臂
turtle.penup()
turtle.goto(-70, 0)
turtle.pendown()
turtle.color(body_color)
turtle.begin_fill()
turtle.setheading(180)
turtle.circle(70, 30)
turtle.setheading(90)
turtle.forward(20)
turtle.setheading(0)
turtle.circle(-20, 180)
turtle.setheading(-90)
turtle.forward(20)
turtle.setheading(150)
turtle.circle(70, 30)
turtle.end_fill()
turtle.penup()
turtle.goto(70, 0)
turtle.pendown()
turtle.color(body_color)
turtle.begin_fill()
turtle.setheading(0)
turtle.circle(-70, 30)
turtle.setheading(90)
turtle.forward(20)
turtle.setheading(180)
turtle.circle(20, 180)
turtle.setheading(-90)
turtle.forward(20)
turtle.setheading(30)
turtle.circle(-70, 30)
turtle.end_fill()
# 绘制奥特曼腿
turtle.penup()
turtle.goto(-30, -70)
turtle.pendown()
turtle.color(body_color)
turtle.begin_fill()
turtle.setheading(-90)
turtle.forward(50)
turtle.setheading(0)
turtle.circle(-20, 180)
turtle.setheading(90)
turtle.forward(50)
turtle.end_fill()
turtle.penup()
turtle.goto(30, -70)
turtle.pendown()
turtle.color(body_color)
turtle.begin_fill()
turtle.setheading(-90)
turtle.forward(50)
turtle.setheading(180)
turtle.circle(20, 180)
turtle.setheading(90)
turtle.forward(50)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
turtle.done()
```
运行上述代码,即可得到一张奥特曼的图像。
阅读全文