turtle库画蔡徐坤
时间: 2023-07-31 15:11:54 浏览: 191
好的,下面是使用turtle库画蔡徐坤的示例代码:
```python
import turtle
# 设置画布大小和背景颜色
turtle.setup(500, 500)
turtle.bgcolor("white")
# 开始画蔡徐坤
turtle.speed(10)
# 画头部
turtle.penup()
turtle.goto(0, 100)
turtle.pendown()
turtle.color("black")
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
# 画眼睛
turtle.penup()
turtle.goto(-20, 120)
turtle.pendown()
turtle.color("white")
turtle.begin_fill()
turtle.circle(15)
turtle.end_fill()
turtle.penup()
turtle.goto(20, 120)
turtle.pendown()
turtle.begin_fill()
turtle.circle(15)
turtle.end_fill()
turtle.penup()
turtle.goto(-15, 130)
turtle.pendown()
turtle.color("black")
turtle.begin_fill()
turtle.circle(5)
turtle.end_fill()
turtle.penup()
turtle.goto(15, 130)
turtle.pendown()
turtle.begin_fill()
turtle.circle(5)
turtle.end_fill()
# 画嘴巴
turtle.penup()
turtle.goto(-30, 80)
turtle.pendown()
turtle.color("black")
turtle.right(45)
turtle.circle(30, 90)
turtle.left(135)
turtle.circle(-30, 90)
# 画身体
turtle.penup()
turtle.goto(0, 0)
turtle.pendown()
turtle.color("black")
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 画手
turtle.penup()
turtle.goto(-75, 0)
turtle.pendown()
turtle.color("black")
turtle.begin_fill()
turtle.circle(25)
turtle.end_fill()
turtle.penup()
turtle.goto(75, 0)
turtle.pendown()
turtle.color("black")
turtle.begin_fill()
turtle.circle(25)
turtle.end_fill()
# 画腿
turtle.penup()
turtle.goto(-30, -100)
turtle.pendown()
turtle.color("black")
turtle.begin_fill()
turtle.forward(60)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(60)
turtle.end_fill()
turtle.penup()
turtle.goto(30, -100)
turtle.pendown()
turtle.color("black")
turtle.begin_fill()
turtle.forward(60)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(60)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
# 显示绘图窗口
turtle.done()
```
运行以上代码,将会绘制出蔡徐坤的图像,效果如下图所示:
![蔡徐坤](https://img-blog.csdnimg.cn/20210711150043768.png)
阅读全文