使用Python绘制一个冰墩墩

北京冬奥会已经结束了,在这疫情之下,能取得这样的成功殊为不易。在冬奥期间,除了运动员们取得的成绩、让人经验的开闭幕式外,憨憨的冬奥吉祥物冰墩墩也深受大家的喜爱,一时间一墩难求。即使冬奥已经闭幕,排队购买冰墩墩的人还是大有人在。既然暂时我们没法买到冰墩墩,那我们就发挥我们的特长,使用Python来绘制一个冰墩墩吧。
以下是使用Python冰墩墩的一些核心代码:

  1. # 左手
  2. turtle.penup()
  3. turtle.goto(177, 112)
  4. turtle.pencolor("lightgray")
  5. turtle.pensize(3)
  6. turtle.fillcolor("white")
  7. turtle.begin_fill()
  8. turtle.pendown()
  9. turtle.setheading(80)
  10. turtle.circle(-45,200,360)
  11. turtle.circle(-300,23,360)
  12. turtle.end_fill()
  13. # 左手内
  14. turtle.penup()
  15. turtle.goto(182, 95)
  16. turtle.pencolor("black")
  17. turtle.pensize(1)
  18. turtle.fillcolor("black")
  19. turtle.begin_fill()
  20. turtle.setheading(95)
  21. turtle.pendown()
  22. turtle.circle(-37, 160,360)
  23. turtle.circle(-20, 50,360)
  24. turtle.circle(-200, 30,360)
  25. turtle.end_fill()
  26. # 轮廓
  27. # 头顶
  28. turtle.penup()
  29. turtle.goto(-73, 230)
  30. turtle.pencolor("lightgray")
  31. turtle.pensize(3)
  32. turtle.fillcolor("white")
  33. turtle.begin_fill()
  34. turtle.pendown()
  35. turtle.setheading(20)
  36. turtle.circle(-250, 35,360)
  37. # 左耳
  38. turtle.setheading(50)
  39. turtle.circle(-42, 180,360)
  40. # 左侧
  41. turtle.setheading(-50)
  42. turtle.circle(-190, 30,360)
  43. turtle.circle(-320, 45,360)
  44. # 左腿
  45. turtle.circle(120, 30,360)
  46. turtle.circle(200, 12,360)
  47. turtle.circle(-18, 85,360)
  48. turtle.circle(-180, 23,360)
  49. turtle.circle(-20, 110,360)
  50. turtle.circle(15, 115,360)
  51. turtle.circle(100, 12,360)
  52. # 右腿
  53. turtle.circle(15, 120,360)
  54. turtle.circle(-15, 110,360)
  55. turtle.circle(-150, 30,360)
  56. turtle.circle(-15, 70,360)
  57. turtle.circle(-150, 10,360)
  58. turtle.circle(200, 35,360)
  59. turtle.circle(-150, 20,360)
  60. # 右手
  61. turtle.setheading(-120)
  62. turtle.circle(50, 30,360)
  63. turtle.circle(-35, 200,360)
  64. turtle.circle(-300, 23,360)
  65. # 右侧
  66. turtle.setheading(86)
  67. turtle.circle(-300, 26,360)
  68. # 右耳
  69. turtle.setheading(122)
  70. turtle.circle(-53, 160,360)
  71. turtle.end_fill()
  72. # 右耳内
  73. turtle.penup()
  74. turtle.goto(-130, 180)
  75. turtle.pencolor("black")
  76. turtle.pensize(1)
  77. turtle.fillcolor("black")
  78. turtle.begin_fill()
  79. turtle.pendown()
  80. turtle.setheading(120)
  81. turtle.circle(-28, 160,360)
  82. turtle.setheading(210)
  83. turtle.circle(150, 20,360)
  84. turtle.end_fill()
  85. # 左耳内
  86. turtle.penup()
  87. turtle.goto(90, 230)
  88. turtle.setheading(40)
  89. turtle.begin_fill()
  90. turtle.pendown()
  91. turtle.circle(-30, 170,360)
  92. turtle.setheading(125)
  93. turtle.circle(150, 23,360)
  94. turtle.end_fill()
  95. # 右手内
  96. turtle.penup()
  97. turtle.goto(-180, -55)
  98. turtle.fillcolor("black")
  99. turtle.begin_fill()
  100. turtle.setheading(-120)
  101. turtle.pendown()
  102. turtle.circle(50, 30,360)
  103. turtle.circle(-27, 200,360)
  104. turtle.circle(-300, 20,360)
  105. turtle.setheading(-90)
  106. turtle.circle(300, 14,360)
  107. turtle.end_fill()

完整的代码可以在好学好教少儿编程教学平台的Python作品中找到。点此《使用Python绘制冰墩墩》直达。

微信扫一扫,分享此文章

少儿编程教学平台

联系我们

微信

aguibo002

邮箱

haoxuehaojiao在163.com

Loading
我们已经收到您的信息,将尽快联系您!