用python 画东方明珠
时间: 2023-10-17 12:05:30 浏览: 141
你可以使用 Python 中的 Turtle 模块来画出东方明珠。
首先,导入 turtle 模块:
```python
import turtle
```
然后设置画布的大小和背景颜色:
```python
turtle.setup(500, 500)
turtle.bgcolor("black")
```
接下来,定义一个函数来画出东方明珠的主体:
```python
def draw_pearl():
# 绘制大圆球
turtle.color("white", "white")
turtle.begin_fill()
turtle.circle(200)
turtle.end_fill()
# 绘制中间的球
turtle.color("black", "black")
turtle.begin_fill()
turtle.circle(150)
turtle.end_fill()
# 绘制小球
turtle.penup()
turtle.goto(0, -200)
turtle.pendown()
turtle.color("white", "white")
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
```
最后,调用该函数即可绘制出东方明珠:
```python
draw_pearl()
turtle.done()
```
完整代码:
```python
import turtle
def draw_pearl():
# 绘制大圆球
turtle.color("white", "white")
turtle.begin_fill()
turtle.circle(200)
turtle.end_fill()
# 绘制中间的球
turtle.color("black", "black")
turtle.begin_fill()
turtle.circle(150)
turtle.end_fill()
# 绘制小球
turtle.penup()
turtle.goto(0, -200)
turtle.pendown()
turtle.color("white", "white")
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
turtle.setup(500, 500)
turtle.bgcolor("black")
draw_pearl()
turtle.done()
```
阅读全文
相关推荐




