python Turtle 简笔画 玉桂狗
时间: 2023-11-24 08:53:28 浏览: 130
以下是使用Python Turtle绘制玉桂狗的代码和效果图:
```python
import turtle
# 设置画笔
t = turtle.Pen()
t.pensize(5)
t.speed(10)
# 绘制狗头
t.fillcolor("#F0E68C")
t.begin_fill()
t.circle(50)
t.end_fill()
# 绘制狗耳朵
t.penup()
t.goto(-30, 80)
t.pendown()
t.fillcolor("#F0E68C")
t.begin_fill()
t.right(45)
t.forward(40)
t.right(90)
t.forward(40)
t.right(90)
t.forward(40)
t.right(135)
t.forward(56)
t.end_fill()
t.penup()
t.goto(30, 80)
t.pendown()
t.fillcolor("#F0E68C")
t.begin_fill()
t.left(45)
t.forward(40)
t.left(90)
t.forward(40)
t.left(90)
t.forward(40)
t.left(135)
t.forward(56)
t.end_fill()
# 绘制狗眼睛
t.penup()
t.goto(-20, 20)
t.pendown()
t.fillcolor("#FFFFFF")
t.begin_fill()
t.circle(15)
t.end_fill()
t.penup()
t.goto(20, 20)
t.pendown()
t.fillcolor("#FFFFFF")
t.begin_fill()
t.circle(15)
t.end_fill()
t.penup()
t.goto(-20, 25)
t.pendown()
t.fillcolor("#000000")
t.begin_fill()
t.circle(8)
t.end_fill()
t.penup()
t.goto(20, 25)
t.pendown()
t.fillcolor("#000000")
t.begin_fill()
t.circle(8)
t.end_fill()
# 绘制狗鼻子
t.penup()
t.goto(0, 0)
t.pendown()
t.fillcolor("#FFA07A")
t.begin_fill()
t.circle(10)
t.end_fill()
# 绘制狗嘴巴
t.penup()
t.goto(-30, -20)
t.pendown()
t.right(45)
t.forward(60)
t.right(90)
t.forward(30)
t.right(90)
t.forward(60)
# 绘制狗身体
t.penup()
t.goto(-100, -100)
t.pendown()
t.fillcolor("#F0E68C")
t.begin_fill()
t.right(45)
t.forward(200)
t.right(90)
t.forward(100)
t.right(90)
t.forward(200)
t.right(135)
t.forward(140)
t.end_fill()
# 绘制狗腿
t.penup()
t.goto(-100, -100)
t.pendown()
t.fillcolor("#F0E68C")
t.begin_fill()
t.right(45)
t.forward(60)
t.right(90)
t.forward(30)
t.right(90)
t.forward(60)
t.right(135)
t.forward(42)
t.end_fill()
t.penup()
t.goto(100, -100)
t.pendown()
t.fillcolor("#F0E68C")
t.begin_fill()
t.left(45)
t.forward(60)
t.left(90)
t.forward(30)
t.left(90)
t.forward(60)
t.left(135)
t.forward(42)
t.end_fill()
# 隐藏画笔
t.hideturtle()
# 等待用户关闭窗口
turtle.done()
```
效果图如下:
![玉桂狗](https://i.loli.net/2021/08/23/9J5zvZ6K8Q7q1Lr.png)