下面是一个使用Python Turtle模块绘制雪人的示例代码:
import turtle
# 设置画布
turtle.setup(800, 600)
turtle.bgcolor("skyblue")
turtle.title("Snowman")
# 绘制雪人身体
turtle.penup()
turtle.goto(-100, -100)
turtle.pendown()
turtle.begin_fill()
turtle.circle(40)
turtle.end_fill()
# 绘制雪人头部
turtle.penup()
turtle.goto(-100, 0)
turtle.pendown()
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
# 绘制雪人眼睛
turtle.penup()
turtle.goto(-115, 10)
turtle.pendown()
turtle.begin_fill()
turtle.circle(3)
turtle.end_fill()
turtle.penup()
turtle.goto(-85, 10)
turtle.pendown()
turtle.begin_fill()
turtle.circle(3)
turtle.end_fill()
# 绘制雪人鼻子
turtle.penup()
turtle.goto(-100, -10)
turtle.pendown()
turtle.pensize(3)
turtle.pencolor("orange")
turtle.setheading(60)
turtle.circle(10, 120)
turtle.setheading(180)
turtle.circle(10, 120)
turtle.setheading(0)
turtle.circle(10, 120)
# 绘制雪人帽子
turtle.penup()
turtle.goto(-135, 50)
turtle.pendown()
turtle.begin_fill()
turtle.color("red")
turtle.forward(70)
turtle.left(90)
turtle.forward(30)
turtle.left(90)
turtle.forward(70)
turtle.left(90)
turtle.forward(30)
turtle.end_fill()
# 绘制雪人围巾
turtle.penup()
turtle.goto(-100, -20)
turtle.pendown()
turtle.pensize(5)
turtle.pencolor("green")
turtle.setheading(-90)
turtle.forward(50)
turtle.right(90)
turtle.forward(30)
turtle.right(90)
turtle.forward(60)
turtle.hideturtle()
turtle.done()
运行上述代码后,将会在画布上绘制出一个可爱的雪人。你可以根据自己的喜好进行各部分的样式修改。