python画柯南源代码
时间: 2023-08-25 13:17:40 浏览: 175
python画柯南代码直接用
5星 · 资源好评率100%
当然,下面是使用Python绘制柯南的源代码:
```python
import turtle
def draw_conan():
# 设置窗口大小和背景颜色
turtle.setup(800, 600)
turtle.bgcolor("white")
# 设置画笔颜色和宽度
turtle.pensize(2)
turtle.color("black")
# 绘制头部
turtle.penup()
turtle.goto(0, -100)
turtle.pendown()
turtle.circle(100)
# 绘制眼睛
turtle.penup()
turtle.goto(-40, 50)
turtle.pendown()
turtle.circle(20)
turtle.penup()
turtle.goto(40, 50)
turtle.pendown()
turtle.circle(20)
# 绘制嘴巴
turtle.penup()
turtle.goto(-60, -20)
turtle.pendown()
turtle.right(90)
turtle.circle(60, 180)
# 绘制身体
turtle.penup()
turtle.goto(-100, -200)
turtle.pendown()
turtle.forward(200)
turtle.right(90)
turtle.forward(300)
turtle.right(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(300)
# 绘制裤子
turtle.penup()
turtle.goto(-100, -200)
turtle.pendown()
turtle.color("blue")
turtle.begin_fill()
turtle.forward(200)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(100)
turtle.end_fill()
# 绘制鞋子
turtle.penup()
turtle.goto(-100, -400)
turtle.pendown()
turtle.color("black")
turtle.begin_fill()
turtle.forward(80)
turtle.right(90)
turtle.forward(40)
turtle.right(90)
turtle.forward(80)
turtle.right(90)
turtle.forward(40)
turtle.end_fill()
turtle.penup()
turtle.goto(20, -400)
turtle.pendown()
turtle.begin_fill()
turtle.forward(80)
turtle.right(90)
turtle.forward(40)
turtle.right(90)
turtle.forward(80)
turtle.right(90)
turtle.forward(40)
turtle.end_fill()
# 绘制手臂
turtle.penup()
turtle.goto(-200, -100)
turtle.pendown()
turtle.color("black")
turtle.begin_fill()
turtle.forward(100)
turtle.right(90)
turtle.forward(20)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(20)
turtle.end_fill()
turtle.penup()
turtle.goto(100, -100)
turtle.pendown()
turtle.begin_fill()
turtle.forward(100)
turtle.left(90)
turtle.forward(20)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(20)
turtle.end_fill()
# 绘制手
turtle.penup()
turtle.goto(-200, -120)
turtle.pendown()
turtle.color("yellow")
turtle.begin_fill()
turtle.forward(20)
turtle.right(90)
turtle.forward(40)
turtle.right(90)
turtle.forward(20)
turtle.right(90)
turtle.forward(40)
turtle.end_fill()
turtle.penup()
turtle.goto(100, -120)
turtle.pendown()
turtle.begin_fill()
turtle.forward(20)
turtle.left(90)
turtle.forward(40)
turtle.left(90)
turtle.forward(20)
turtle.left(90)
turtle.forward(40)
turtle.end_fill()
# 绘制脚
turtle.penup()
turtle.goto(-140, -400)
turtle.pendown()
turtle.color("black")
turtle.begin_fill()
turtle.forward(40)
turtle.right(90)
turtle.forward(80)
turtle.right(90)
turtle.forward(40)
turtle.right(90)
turtle.forward(80)
turtle.end_fill()
turtle.penup()
turtle.goto(60, -400)
turtle.pendown()
turtle.begin_fill()
turtle.forward(40)
turtle.right(90)
turtle.forward(80)
turtle.right(90)
turtle.forward(40)
turtle.right(90)
turtle.forward(80)
turtle.end_fill()
# 完成绘制
turtle.done()
# 调用绘制函数
draw_conan()
```
以上就是使用Python绘制柯南的简单示例代码。你可以将代码复制到Python编辑器中运行,即可看到绘制结果。希望能帮到你!
阅读全文