以下是一个利用Python画出冰墩墩的完整源代码:
import turtle
# 设置画布大小和背景颜色
turtle.setup(800, 600)
turtle.bgcolor("#0077be")
# 设置画笔属性
turtle.penup()
turtle.speed(10)
turtle.hideturtle()
# 画出冰墩墩的身体
turtle.goto(-100, 0)
turtle.pendown()
turtle.fillcolor("#ffffff")
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 画出冰墩墩的脸部
turtle.penup()
turtle.goto(-50, 50)
turtle.pendown()
turtle.fillcolor("#000000")
turtle.begin_fill()
turtle.circle(15)
turtle.end_fill()
# 画出冰墩墩的眼睛
turtle.penup()
turtle.goto(-60, 60)
turtle.pendown()
turtle.fillcolor("#ffffff")
turtle.begin_fill()
turtle.circle(5)
turtle.end_fill()
turtle.penup()
turtle.goto(-40, 60)
turtle.pendown()
turtle.fillcolor("#ffffff")
turtle.begin_fill()
turtle.circle(5)
turtle.end_fill()
# 画出冰墩墩的嘴巴
turtle.penup()
turtle.goto(-70, 40)
turtle.pendown()
turtle.pensize(3)
turtle.right(90)
turtle.circle(70, 180)
# 画出冰墩墩的帽子
turtle.penup()
turtle.goto(-100, 100)
turtle.pendown()
turtle.fillcolor("#ff0000")
turtle.begin_fill()
turtle.forward(200)
turtle.right(90)
turtle.forward(30)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(30)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(30)
turtle.right(90)
turtle.forward(70)
turtle.right(90)
turtle.end_fill()
# 画出冰墩墩的围巾
turtle.penup()
turtle.goto(-100, -70)
turtle.pendown()
turtle.pensize(10)
turtle.pencolor("#ff0000")
turtle.right(45)
turtle.forward(100)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(50)
turtle.left(135)
turtle.done()
运行该代码,即可在turtle图形窗口中看到画出的冰墩墩形状。