鱼C论坛

 找回密码
 立即注册
查看: 2404|回复: 4

[学习笔记] 用python画皮卡丘

[复制链接]
发表于 2020-3-9 08:56:40 | 显示全部楼层 |阅读模式

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

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

x
  1. # coding:utf-8
  2. import turtle as t
  3. def infoPrt():
  4.     print('coordinate: ' + str(t.pos()))
  5.     print('angle: ' + str(t.heading()))
  6. t.pensize(3)
  7. t.hideturtle()
  8. t.colormode(255)
  9. t.color("black")
  10. t.setup(700, 650)
  11. t.speed(10)
  12. t.st()
  13. #t.dot()
  14. t.pu()
  15. #t.goto(-150,100)
  16. t.goto(-210,86)
  17. t.pd()
  18. infoPrt()
  19. # 头
  20. print('头')
  21. t.seth(85)
  22. t.circle(-100,50)
  23. #t.seth(78)
  24. #t.circle(-100,25)
  25. infoPrt()
  26. t.seth(25)
  27. t.circle(-170,50)
  28. infoPrt()
  29. # 右耳
  30. print('右耳')
  31. t.seth(40)
  32. #t.circle(-250,52)
  33. t.circle(-250,30)
  34. infoPrt()
  35. # 右耳尖
  36. t.begin_fill()
  37. # 左
  38. t.circle(-250,22)
  39. #t.fillcolor("pink")
  40. # 右
  41. t.seth(227)
  42. t.circle(-270, 15)
  43. prePos = t.pos()
  44. infoPrt()
  45. # 下
  46. t.seth(105)
  47. t.circle(100, 32)
  48. t.end_fill()
  49. t.pu()
  50. t.setpos(prePos)
  51. t.pd()
  52. t.seth(212)
  53. t.circle(-270, 28)
  54. prePos = t.pos()
  55. t.pu()
  56. t.goto(t.xcor()+5,t.ycor()-2)
  57. t.pd()
  58. # 躯干
  59. print('躯干')
  60. t.seth(280)
  61. t.circle(500, 30)
  62. infoPrt()
  63. # 臀部
  64. print('臀部')
  65. t.seth(120)
  66. #t.circle(150, -55)
  67. t.circle(150, -11)
  68. p_tail=t.pos()
  69. t.circle(150, -44)
  70. p_butt=t.pos()
  71. infoPrt()
  72. # 尾巴
  73. t.pu()
  74. t.setpos(p_tail)
  75. t.pd()
  76. t.begin_fill()
  77. t.seth(50)
  78. t.fd(25)
  79. t.seth(-50)
  80. t.fd(30)
  81. p_tail1=t.pos
  82. t.seth(-140)
  83. t.fd(36)
  84. t.end_fill()
  85. t.seth(39)
  86. # 右尾和h1
  87. t.fd(72)
  88. # 右尾和v1
  89. t.seth(125)
  90. t.fd(48)
  91. # 右尾和h2
  92. t.seth(40)
  93. t.fd(53)
  94. # 右尾和v2
  95. t.seth(88)
  96. t.fd(45)
  97. # 右尾和h3
  98. t.seth(35)
  99. t.fd(105)
  100. # 右尾和v3
  101. t.seth(105)
  102. t.circle(850, 8)
  103. #t.fd(105)
  104. t.seth(215)
  105. #t.fd(125)
  106. t.circle(850, 11)
  107. t.seth(280)
  108. t.fd(110)
  109. t.seth(220)
  110. t.fd(50)
  111. t.seth(309)
  112. t.fd(56)
  113. # 底盘
  114. print('底盘')
  115. t.pu()
  116. t.setpos(p_butt)
  117. t.pd()
  118. t.seth(20)
  119. t.circle(120, -45)
  120. infoPrt()
  121. t.seth(330)
  122. t.circle(-150, -30)
  123. infoPrt()
  124. prePos = t.pos()
  125. t.pu()
  126. t.goto(t.xcor()+20,t.ycor())
  127. t.pd()
  128. t.seth(230)
  129. t.circle(-70, 120)
  130. p_bot=t.pos()
  131. # 两脚-right
  132. t.pu()
  133. t.setpos(p_butt)
  134. t.setpos(t.xcor()+5,t.ycor()+5)
  135. t.pd()
  136. t.seth(-86)
  137. t.fd(30)
  138. t.seth(-93)
  139. t.fd(33)
  140. t.seth(-225)
  141. t.circle(-150, 22)
  142. # 两脚-left
  143. t.pu()
  144. t.setpos(p_bot)
  145. t.setpos(t.xcor()+85,t.ycor()-43)
  146. t.pd()
  147. t.seth(-105)
  148. t.fd(50)
  149. t.seth(-225)
  150. t.circle(-150, 22)
  151. # 左躯干
  152. print('躯干')
  153. t.pu()
  154. t.setpos(p_bot)
  155. t.pd()
  156. t.seth(90)
  157. t.circle(450, 13)
  158. p_lfhd = t.pos()
  159. t.circle(450, 5)
  160. t.pu()
  161. t.circle(450, 5)
  162. t.pd()
  163. t.circle(450, 6)
  164. infoPrt()
  165. # 左脸
  166. print('左脸')
  167. t.seth(330)
  168. t.circle(50, -90)
  169. infoPrt()
  170. # 左酒窝
  171. t.seth(30)
  172. t.circle(-15, 120)
  173. t.seth(-70)
  174. t.circle(-30, 90)
  175. # 左手
  176. t.pu()
  177. t.setpos(p_lfhd)
  178. t.pd()
  179. t.seth(160)
  180. t.circle(150, 30)
  181. infoPrt()
  182. t.seth(180)
  183. t.circle(-30, 150)
  184. t.fd(67)
  185. t.pu()
  186. t.setpos(t.xcor()-40,t.ycor()-60)
  187. t.pd()
  188. t.seth(200)
  189. t.circle(-5, 180)
  190. # 右手
  191. t.pu()
  192. t.setpos(p_lfhd)
  193. t.setpos(t.xcor()+180,t.ycor()+5)
  194. t.pd()
  195. t.seth(200)
  196. t.circle(-50, 100)
  197. t.pu()
  198. t.circle(-50, 15)
  199. t.pd()
  200. t.circle(-50, 65)
  201. t.pu()
  202. t.setpos(t.xcor()+10,t.ycor()-45)
  203. t.pd()
  204. #t.seth(270)
  205. #t.circle(-30, -180)
  206. t.seth(80)
  207. t.fd(10)
  208. t.seth(165)
  209. t.circle(10, 60)
  210. t.seth(90)
  211. t.fd(5)
  212. t.seth(165)
  213. t.circle(10, 60)
  214. t.seth(95)
  215. t.fd(5)
  216. t.seth(185)
  217. t.circle(10, 60)
  218. t.seth(105)
  219. t.fd(10)
  220. t.seth(230)
  221. t.fd(20)
  222. t.seth(145)
  223. t.fd(10)
  224. t.seth(285)
  225. t.fd(20)
  226. # 右酒窝
  227. t.pu()
  228. t.setpos(t.xcor()-40,t.ycor()+110)
  229. t.pd()
  230. t.circle(27, 360)
  231. # 嘴
  232. t.pu()
  233. t.setpos(t.xcor()-30,t.ycor()+28)
  234. t.pd()
  235. t.seth(280)
  236. t.circle(-130, 30)
  237. t.seth(270)
  238. t.circle(-6, 160)
  239. t.seth(130)
  240. t.circle(-130, 30)
  241. t.pu()
  242. t.setpos(t.xcor()-5,t.ycor()+5)
  243. t.pd()
  244. t.seth(160)
  245. t.circle(-20, -70)
  246. t.seth(160)
  247. t.circle(-30, -60)
  248. t.pu()
  249. t.setpos(t.xcor(),t.ycor()-28)
  250. t.pd()
  251. t.seth(200)
  252. t.circle(50, 58)
  253. # 左眼
  254. t.pu()
  255. t.setpos(t.xcor()-40,t.ycor()+90)
  256. t.pd()
  257. t.circle(5)
  258. t.pu()
  259. t.setpos(t.xcor()+5,t.ycor()+10)
  260. t.pd()
  261. t.begin_fill()
  262. t.seth(190)
  263. t.circle(15, 130)
  264. t.seth(310)
  265. t.circle(10, 15)
  266. t.seth(0)
  267. t.circle(17, 133)
  268. t.seth(90)
  269. t.circle(10, 15)
  270. t.end_fill()
  271. t.pu()
  272. t.setpos(t.xcor()+2,t.ycor()-15)
  273. t.pd()
  274. t.color("white")
  275. t.begin_fill()
  276. t.circle(5)
  277. t.end_fill()
  278. # 右眼
  279. t.pu()
  280. t.setpos(t.xcor()+85,t.ycor()+15)
  281. t.pd()
  282. t.color("black")
  283. t.circle(5)
  284. t.pu()
  285. t.setpos(t.xcor()+5,t.ycor()+10)
  286. t.pd()
  287. t.begin_fill()
  288. t.seth(190)
  289. t.circle(20, 130)
  290. t.seth(310)
  291. t.circle(10, 15)
  292. t.seth(0)
  293. t.circle(22, 133)
  294. t.seth(90)
  295. t.circle(13, 15)
  296. t.end_fill()
  297. t.pu()
  298. t.setpos(t.xcor()-7,t.ycor()-15)
  299. t.pd()
  300. t.color("white")
  301. t.begin_fill()
  302. t.circle(7)
  303. t.end_fill()
  304. # 左耳
  305. t.color("black")
  306. t.pu()
  307. t.goto(-210,86)
  308. t.setpos(t.xcor()+15,t.ycor()+38)
  309. t.pd()
  310. t.seth(90)
  311. t.circle(-250,30)
  312. t.begin_fill()
  313. # 左
  314. t.circle(-250,18)
  315. # 右
  316. t.seth(270)
  317. t.circle(-270, 12)
  318. prePos = t.pos()
  319. # 下
  320. t.seth(180)
  321. t.circle(100, 30)
  322. t.end_fill()
  323. t.pu()
  324. t.setpos(prePos)
  325. t.pd()
  326. t.seth(270)
  327. t.circle(-270, 18)
  328. t.done()

复制代码

本帖被以下淘专辑推荐:

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

使用道具 举报

发表于 2020-4-1 17:09:02 | 显示全部楼层
优秀
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-4-8 20:37:42 | 显示全部楼层
强啊
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-4-8 23:28:56 | 显示全部楼层
厉害厉害
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-12-18 22:11:21 | 显示全部楼层
66666666666666666666666666666666666666666666666666666666666666666666666666666666666666
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-4-26 20:52

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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