用python画蔡徐坤代码
时间: 2023-09-21 10:11:16 浏览: 384
以下是用Python绘制蔡徐坤的示例代码:
```python
import turtle
# 画圆
def draw_circle(x, y, radius, color):
turtle.penup()
turtle.setposition(x, y)
turtle.color(color)
turtle.pendown()
turtle.begin_fill()
turtle.circle(radius)
turtle.end_fill()
# 画矩形
def draw_rectangle(x, y, width, height, color):
turtle.penup()
turtle.setposition(x, y)
turtle.color(color)
turtle.pendown()
turtle.begin_fill()
for i in range(2):
turtle.forward(width)
turtle.right(90)
turtle.forward(height)
turtle.right(90)
turtle.end_fill()
# 画蔡徐坤
def draw_cxk():
turtle.speed(0) # 设置画笔速度
draw_circle(0, 0, 100, '#F9D342') # 画脸部
draw_circle(-60, 60, 20, '#FFFFFF') # 画左眼
draw_circle(60, 60, 20, '#FFFFFF') # 画右眼
draw_circle(-60, 60, 10, '#000000') # 画左眼珠
draw_circle(60, 60, 10, '#000000') # 画右眼珠
draw_rectangle(-70, -20, 140, 30, '#F9D342') # 画嘴巴
# 启动画布
turtle.setup(500, 500)
turtle.bgcolor('#FF6EB4') # 设置背景颜色
draw_cxk()
turtle.done()
```
运行以上代码将得到蔡徐坤的画像。
阅读全文