用python画一只柯基
时间: 2023-10-16 13:10:58 浏览: 148
非常荣幸为您服务!以下是使用Python绘制柯基的代码示例:
```
import turtle
#设置画布
canvas = turtle.Screen()
canvas.bgcolor("white")
canvas.title("Corgi Drawing")
#绘制身体
pen = turtle.Turtle()
pen.color("brown")
pen.speed(1)
pen.penup()
pen.goto(0, -100)
pen.pendown()
pen.begin_fill()
pen.circle(100)
pen.end_fill()
#绘制腿
pen.penup()
pen.goto(50, -150)
pen.pendown()
pen.setheading(60)
pen.forward(60)
pen.backward(60)
pen.penup()
pen.goto(-50, -150)
pen.pendown()
pen.setheading(120)
pen.forward(60)
pen.backward(60)
#绘制尾巴
pen.penup()
pen.goto(75, -75)
pen.pendown()
pen.setheading(-45)
pen.circle(40, 90)
pen.right(90)
pen.circle(40, 90)
#绘制头部
pen.penup()
pen.goto(-50, 50)
pen.pendown()
pen.color("white")
pen.begin_fill()
pen.circle(50)
pen.end_fill()
#绘制眼睛
pen.penup()
pen.goto(-25, 75)
pen.pendown()
pen.color("black")
pen.begin_fill()
pen.circle(10)
pen.end_fill()
pen.penup()
pen.goto(25, 75)
pen.pendown()
pen.color("black")
pen.begin_fill()
pen.circle(10)
pen.end_fill()
#绘制鼻子
pen.penup()
pen.goto(0, 50)
pen.pendown()
pen.color("black")
pen.begin_fill()
pen.circle(15)
pen.end_fill()
#绘制嘴巴
pen.penup()
pen.goto(0, 30)
pen.pendown()
pen.color("black")
pen.right(90)
pen.circle(10, 180)
#隐藏画笔
pen.hideturtle()
turtle.done()
```
希望这个代码示例对您有帮助,如果有任何问题,请随时告诉我。
阅读全文