在Windows系统下用python编写一个的程序:画出电影“加勒比海盗”里的Jack Sparrow
时间: 2023-06-19 19:02:58 浏览: 121
以下是使用turtle库实现的Jack Sparrow的绘制程序:
```python
import turtle
# 设置画布大小和背景颜色
turtle.setup(800, 600)
turtle.bgcolor('#f0f0f0')
# 定义画笔颜色和粗细
turtle.pensize(4)
turtle.pencolor('#000000')
# 绘制眼睛
turtle.fillcolor('#ffffff')
turtle.begin_fill()
turtle.circle(40)
turtle.end_fill()
turtle.penup()
turtle.goto(-20, 10)
turtle.fillcolor('#000000')
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 绘制眼罩
turtle.penup()
turtle.goto(-60, 40)
turtle.pendown()
turtle.pensize(2)
turtle.pencolor('#000000')
turtle.fillcolor('#000000')
turtle.begin_fill()
turtle.goto(60, 40)
turtle.goto(60, 20)
turtle.goto(-60, 20)
turtle.goto(-60, 40)
turtle.end_fill()
# 绘制帽子
turtle.penup()
turtle.goto(-120, 80)
turtle.pendown()
turtle.pensize(4)
turtle.pencolor('#000000')
turtle.fillcolor('#000000')
turtle.begin_fill()
turtle.goto(120, 80)
turtle.goto(80, 160)
turtle.goto(-80, 160)
turtle.goto(-120, 80)
turtle.end_fill()
# 绘制头发
turtle.penup()
turtle.goto(-100, 120)
turtle.pendown()
turtle.pencolor('#000000')
turtle.fillcolor('#000000')
turtle.begin_fill()
turtle.goto(-60, 80)
turtle.goto(-40, 120)
turtle.end_fill()
turtle.penup()
turtle.goto(100, 120)
turtle.pendown()
turtle.pencolor('#000000')
turtle.fillcolor('#000000')
turtle.begin_fill()
turtle.goto(60, 80)
turtle.goto(40, 120)
turtle.end_fill()
# 绘制胡须
turtle.penup()
turtle.goto(-60, -20)
turtle.pendown()
turtle.pencolor('#000000')
turtle.goto(-80, -40)
turtle.penup()
turtle.goto(60, -20)
turtle.pendown()
turtle.pencolor('#000000')
turtle.goto(80, -40)
turtle.penup()
turtle.goto(-80, -60)
turtle.pendown()
turtle.pencolor('#000000')
turtle.goto(0, -40)
turtle.penup()
turtle.goto(80, -60)
turtle.pendown()
turtle.pencolor('#000000')
turtle.goto(0, -40)
# 隐藏画笔
turtle.hideturtle()
# 显示绘图窗口
turtle.done()
```
运行程序后,可以看到绘制出来的Jack Sparrow的图像。
阅读全文