用代码实现画一个冰墩墩
时间: 2023-03-21 14:02:32 浏览: 107
以下是使用Python语言和Turtle库绘制冰墩墩的代码:
```python
import turtle
# 创建画布和画笔
screen = turtle.Screen()
pen = turtle.Turtle()
# 设置画笔的属性
pen.speed(0)
pen.pensize(5)
# 绘制下半部分冰墩墩的圆形
pen.fillcolor('#82c4c3')
pen.begin_fill()
pen.circle(100)
pen.end_fill()
# 绘制上半部分冰墩墩的圆形
pen.fillcolor('#ffffff')
pen.begin_fill()
pen.circle(80)
pen.end_fill()
# 绘制眼睛
pen.penup()
pen.goto(-40, 60)
pen.pendown()
pen.fillcolor('#000000')
pen.begin_fill()
pen.circle(10)
pen.end_fill()
pen.penup()
pen.goto(40, 60)
pen.pendown()
pen.fillcolor('#000000')
pen.begin_fill()
pen.circle(10)
pen.end_fill()
# 绘制嘴巴
pen.penup()
pen.goto(-60, 20)
pen.pendown()
pen.pensize(2)
pen.right(45)
pen.circle(60, 90)
# 隐藏画笔
pen.hideturtle()
# 点击关闭按钮退出程序
screen.exitonclick()
```
运行上述代码将在窗口中绘制一个冰墩墩。
阅读全文