北京冬奥会已经结束了,在这疫情之下,能取得这样的成功殊为不易。在冬奥期间,除了运动员们取得的成绩、让人经验的开闭幕式外,憨憨的冬奥吉祥物冰墩墩也深受大家的喜爱,一时间一墩难求。即使冬奥已经闭幕,排队购买冰墩墩的人还是大有人在。既然暂时我们没法买到冰墩墩,那我们就发挥我们的特长,使用Python来绘制一个冰墩墩吧。
以下是使用Python冰墩墩的一些核心代码:
# 左手
turtle.penup()
turtle.goto(177, 112)
turtle.pencolor("lightgray")
turtle.pensize(3)
turtle.fillcolor("white")
turtle.begin_fill()
turtle.pendown()
turtle.setheading(80)
turtle.circle(-45,200,360)
turtle.circle(-300,23,360)
turtle.end_fill()
# 左手内
turtle.penup()
turtle.goto(182, 95)
turtle.pencolor("black")
turtle.pensize(1)
turtle.fillcolor("black")
turtle.begin_fill()
turtle.setheading(95)
turtle.pendown()
turtle.circle(-37, 160,360)
turtle.circle(-20, 50,360)
turtle.circle(-200, 30,360)
turtle.end_fill()
# 轮廓
# 头顶
turtle.penup()
turtle.goto(-73, 230)
turtle.pencolor("lightgray")
turtle.pensize(3)
turtle.fillcolor("white")
turtle.begin_fill()
turtle.pendown()
turtle.setheading(20)
turtle.circle(-250, 35,360)
# 左耳
turtle.setheading(50)
turtle.circle(-42, 180,360)
# 左侧
turtle.setheading(-50)
turtle.circle(-190, 30,360)
turtle.circle(-320, 45,360)
# 左腿
turtle.circle(120, 30,360)
turtle.circle(200, 12,360)
turtle.circle(-18, 85,360)
turtle.circle(-180, 23,360)
turtle.circle(-20, 110,360)
turtle.circle(15, 115,360)
turtle.circle(100, 12,360)
# 右腿
turtle.circle(15, 120,360)
turtle.circle(-15, 110,360)
turtle.circle(-150, 30,360)
turtle.circle(-15, 70,360)
turtle.circle(-150, 10,360)
turtle.circle(200, 35,360)
turtle.circle(-150, 20,360)
# 右手
turtle.setheading(-120)
turtle.circle(50, 30,360)
turtle.circle(-35, 200,360)
turtle.circle(-300, 23,360)
# 右侧
turtle.setheading(86)
turtle.circle(-300, 26,360)
# 右耳
turtle.setheading(122)
turtle.circle(-53, 160,360)
turtle.end_fill()
# 右耳内
turtle.penup()
turtle.goto(-130, 180)
turtle.pencolor("black")
turtle.pensize(1)
turtle.fillcolor("black")
turtle.begin_fill()
turtle.pendown()
turtle.setheading(120)
turtle.circle(-28, 160,360)
turtle.setheading(210)
turtle.circle(150, 20,360)
turtle.end_fill()
# 左耳内
turtle.penup()
turtle.goto(90, 230)
turtle.setheading(40)
turtle.begin_fill()
turtle.pendown()
turtle.circle(-30, 170,360)
turtle.setheading(125)
turtle.circle(150, 23,360)
turtle.end_fill()
# 右手内
turtle.penup()
turtle.goto(-180, -55)
turtle.fillcolor("black")
turtle.begin_fill()
turtle.setheading(-120)
turtle.pendown()
turtle.circle(50, 30,360)
turtle.circle(-27, 200,360)
turtle.circle(-300, 20,360)
turtle.setheading(-90)
turtle.circle(300, 14,360)
turtle.end_fill()
完整的代码可以在好学好教少儿编程教学平台的Python作品中找到。点此《使用Python绘制冰墩墩》直达。