鱼C论坛

 找回密码
 立即注册
查看: 2226|回复: 3

[学习笔记] 用Python画小黄人

[复制链接]
发表于 2020-3-19 12:51:26 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 乘号 于 2020-3-19 13:12 编辑
  1. import turtle
  2. t = turtle.Turtle()
  3. wn = turtle.Screen()
  4. turtle.colormode(255)
  5. t.hideturtle()
  6. t.speed(0)
  7. t.penup()
  8. t.pensize(4)
  9. t.goto(100,0)
  10. t.pendown()
  11. t.left(90)
  12. t.color((0,0,0),(255,255,0))
  13. #身体绘制上色
  14. t.begin_fill()
  15. t.forward(200)
  16. t.circle(100,180)
  17. t.forward(200)
  18. t.circle(100,180)
  19. t.end_fill()
  20. #右眼睛绘制上色
  21. t.pensize(12)
  22. t.penup()
  23. t.goto(-100,200)
  24. t.pendown()
  25. t.right(100)
  26. t.circle(500,23)

  27. t.pensize(3)
  28. t.penup()
  29. t.goto(0,200)
  30. t.pendown()
  31. t.seth(270)
  32. t.color("black","white")
  33. t.begin_fill()
  34. t.circle(30)
  35. t.end_fill()

  36. t.penup()
  37. t.goto(15,200)
  38. t.pendown()
  39. t.color("black","black")
  40. t.begin_fill()
  41. t.circle(15)
  42. t.end_fill()

  43. t.penup()
  44. t.goto(35,205)
  45. t.color("black","white")
  46. t.begin_fill()
  47. t.circle(5)
  48. t.end_fill()
  49. #左眼睛绘制上色
  50. t.pensize(3)
  51. t.penup()
  52. t.goto(0,200)
  53. t.pendown()
  54. t.seth(90)
  55. t.color("black","white")
  56. t.begin_fill()
  57. t.circle(30)
  58. t.end_fill()

  59. t.penup()
  60. t.goto(-15,200)
  61. t.pendown()
  62. t.color("black","black")
  63. t.begin_fill()
  64. t.circle(15)
  65. t.end_fill()

  66. t.penup()
  67. t.goto(-35,205)
  68. t.color("black","white")
  69. t.begin_fill()
  70. t.circle(5)
  71. t.end_fill()

  72. #嘴绘制上色
  73. t.penup()
  74. t.goto(-20,100)
  75. t.pendown()
  76. t.seth(270)
  77. t.color("black","white")
  78. t.begin_fill()
  79. t.circle(20,180)
  80. t.left(90)
  81. t.forward(40)
  82. t.end_fill()

  83. #裤子绘制上色
  84. t.penup()
  85. t.goto(-100,0)
  86. t.pendown()
  87. t.seth(0)
  88. t.color("black","blue")
  89. t.begin_fill()
  90. t.forward(20)
  91. t.left(90)
  92. t.forward(40)
  93. t.right(90)
  94. t.forward(160)
  95. t.right(90)
  96. t.forward(40)
  97. t.left(90)
  98. t.forward(20)
  99. t.seth(270)
  100. t.penup()
  101. t.goto(-100,0)
  102. t.circle(100,180)
  103. t.end_fill()

  104. #左裤子腰带
  105. t.penup()
  106. t.goto(-70,20)
  107. t.pendown()
  108. t.color("black","blue")
  109. t.begin_fill()
  110. t.seth(45)
  111. t.forward(15)
  112. t.left(90)
  113. t.forward(60)
  114. t.seth(270)
  115. t.forward(15)
  116. t.left(40)
  117. t.forward(50)
  118. t.end_fill()
  119. t.left(180)
  120. t.goto(-70,30)
  121. t.dot()

  122. #右裤腰带
  123. t.penup()
  124. t.goto(70,20)
  125. t.pendown()
  126. t.color("black","blue")
  127. t.begin_fill()
  128. t.seth(135)
  129. t.forward(15)
  130. t.right(90)
  131. t.forward(60)
  132. t.seth(270)
  133. t.forward(15)
  134. t.right(40)
  135. t.forward(50)
  136. t.end_fill()

  137. t.left(180)
  138. t.goto(70,30)

  139. t.dot()



  140. #脚

  141. t.penup()
  142. t.goto(4,-100)
  143. t.pendown()
  144. t.seth(270)
  145. t.color("black","black")
  146. t.begin_fill()
  147. t.forward(30)
  148. t.left(90)
  149. t.forward(40)
  150. t.seth(20)
  151. t.circle(10,180)
  152. t.circle(400,2)
  153. t.seth(90)
  154. t.forward(20)
  155. t.goto(4,-100)
  156. t.end_fill()

  157. t.penup()
  158. t.goto(-4,-100)
  159. t.pendown()
  160. t.seth(270)
  161. t.color("black","black")
  162. t.begin_fill()
  163. t.forward(30)
  164. t.right(90)
  165. t.forward(40)
  166. t.seth(20)
  167. t.circle(10,-225)
  168. t.circle(400,-3)
  169. t.seth(90)
  170. t.forward(21)
  171. t.goto(-4,-100)
  172. t.end_fill()




  173. #左手
  174. t.penup()
  175. t.goto(-100,50)
  176. t.pendown()
  177. t.seth(225)
  178. t.color("black","yellow")
  179. t.begin_fill()
  180. t.forward(40)
  181. t.left(90)
  182. t.forward(35)
  183. t.seth(90)
  184. t.forward(50)
  185. t.end_fill()
  186. #右手
  187. t.penup()
  188. t.goto(100,50)
  189. t.pendown()
  190. t.seth(315)
  191. t.color("black","yellow")
  192. t.begin_fill()
  193. t.forward(40)
  194. t.right(90)
  195. t.forward(36)
  196. t.seth(90)
  197. t.forward(50)
  198. t.end_fill()

  199. #
  200. t.penup()
  201. t.goto(0,-100)
  202. t.pendown()
  203. t.forward(30)

  204. #
  205. t.penup()
  206. t.goto(0,-20)
  207. t.pendown()
  208. t.color("yellow")
  209. t.begin_fill()
  210. t.seth(45)
  211. t.forward(20)
  212. t.circle(10,180)
  213. t.right(90)
  214. t.circle(10,180)
  215. t.forward(20)
  216. t.end_fill()

  217. #
  218. t.penup()
  219. t.color("black")
  220. t.goto(-100,-20)
  221. t.pendown()
  222. t.circle(30,90)

  223. t.penup()
  224. t.goto(100,-20)
  225. t.pendown()
  226. t.circle(30,-90)
  227. #头顶
  228. t.penup()
  229. t.goto(2,300)
  230. t.pendown()
  231. t.begin_fill()
  232. t.seth(135)
  233. t.circle(100,40)
  234. t.end_fill()

  235. t.penup()
  236. t.goto(2,300)
  237. t.pendown()
  238. t.begin_fill()
  239. t.seth(45)
  240. t.circle(100,40)
  241. t.end_fill()
  242. input()
复制代码





转载地址:
https://www.cnblogs.com/jennyzhangeducation/p/10704190.html

本帖被以下淘专辑推荐:

小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-3-19 13:05:56 | 显示全部楼层
https://www.cnblogs.com/jennyzhangeducation/p/10704190.html
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-3-19 13:06:47 | 显示全部楼层
转载的吧,为什么不附上转载地址?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-3-19 13:13:08 | 显示全部楼层
zltzlt 发表于 2020-3-19 13:06
转载的吧,为什么不附上转载地址?

刚刚忘了,现在加上了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-4-30 23:15

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表