当前位置:   article > 正文

如何用Python画坤坤?_蔡徐坤代码python

蔡徐坤代码python

前言

最近闲得慌,突然想起坤坤了,那就画一个吧。

一、Python画坤坤

坤坤大家都熟悉不过了,也就是蔡徐坤。

代码:

  1. from turtle import *
  2. from math import *
  3. #高级椭圆参数方程(颜色),sita为逆时针旋转角度
  4. def ty_c(x,y,sita,a,b,p,q,c):
  5. fillcolor(c)
  6. si=2*pi/100
  7. penup()
  8. goto(x+a*cos(sita),y+a*sin(sita))
  9. pendown()
  10. t=0
  11. for i in range(201):
  12. if i*si+sita<=p:
  13. penup()
  14. goto(x+a*cos(i*si)*cos(sita)-b*sin(i*si)*sin(sita)\
  15. ,y+a*cos(i*si)*sin(sita)+b*sin(i*si)*cos(sita))
  16. pendown()
  17. elif p<=i*si+sita<=q+2*pi/100:
  18. if t==0:
  19. begin_fill()
  20. t=1
  21. goto(x+a*cos(i*si)*cos(sita)-b*sin(i*si)*sin(sita)\
  22. ,y+a*cos(i*si)*sin(sita)+b*sin(i*si)*cos(sita))
  23. end_fill()
  24. #高级椭圆方程
  25. def ty(x,y,sita,a,b,p,q):
  26. si=2*pi/100
  27. penup()
  28. goto(x+a*cos(sita),y+a*sin(sita))
  29. pendown()
  30. for i in range(201):
  31. if i*si+sita<p:
  32. penup()
  33. goto(x+a*cos(i*si)*cos(sita)-b*sin(i*si)*sin(sita)\
  34. ,y+a*cos(i*si)*sin(sita)+b*sin(i*si)*cos(sita))
  35. pendown()
  36. elif p<=i*si+sita<=q+2*pi/100:
  37. goto(x+a*cos(i*si)*cos(sita)-b*sin(i*si)*sin(sita)\
  38. ,y+a*cos(i*si)*sin(sita)+b*sin(i*si)*cos(sita))
  39. speed(0)
  40. hideturtle()
  41. #篮球
  42. pensize(10)
  43. pencolor('black')
  44. ty_c(350,-267,0,161,161,0,2*pi,'#ff9900')
  45. ty(350,-267+161+50,0,161,161,7*pi/6+pi/12,11*pi/6-pi/12)
  46. ty(350,-267-161-50,0,161,161,pi/6+pi/12,5*pi/6-pi/12)
  47. ty(350,-267+161+330,0,500,500,8.5*pi/6,9.5*pi/6)
  48. #脸
  49. pensize(20)
  50. ty_c(0,0,0,657/2,576/2,0,2*pi,'#ffcc00')
  51. #眼睛
  52. pensize(22)
  53. ty_c(55,52,0,106,104,0,2*pi,'white')
  54. ty_c(-165,60,0,101,99,0,2*pi,'white')
  55. pensize(20)
  56. ty_c(4,79,0,14,14,0,2*pi,'black')
  57. ty_c(-201,80,0,14,14,0,2*pi,'black')
  58. #嘴巴
  59. pensize(12)
  60. ty_c(-66,-76,0,102,62,0,2*pi,'#ff6600')
  61. penup()
  62. goto(-155,-50)
  63. pendown()
  64. goto(-134,-64)
  65. goto(-115,-74)
  66. goto(-90,-82)
  67. goto(-67,-86)
  68. goto(-47,-85)
  69. goto(-25,-82)
  70. goto(0,-77)
  71. goto(15,-66)
  72. goto(25,-55)
  73. #腮红
  74. pensize(1)
  75. pencolor('red')
  76. ty_c(-256,-90,15*pi/180,49,66,0,2*pi+15*pi/180,'red')
  77. ty_c(201,-105,0,73,75,0,2*pi,'red')
  78. #领口
  79. color('black','black')
  80. pensize(10)
  81. penup()
  82. goto(-275,-227)
  83. pendown()
  84. begin_fill()
  85. goto(-241,-209)
  86. goto(-189,-233)
  87. goto(-166,-260)
  88. goto(-127,-272)
  89. goto(-88,-252)
  90. goto(-49,-233)
  91. goto(-19,-227)
  92. goto(51,-237)
  93. goto(108,-242)
  94. goto(168,-242)
  95. goto(210,-233)
  96. goto(250,-206)
  97. goto(252,-254)
  98. goto(216,-269)
  99. goto(-13,-353)
  100. goto(-65,-362)
  101. goto(-109,-356)
  102. goto(-178,-317)
  103. goto(-214,-296)
  104. goto(-246,-266)
  105. goto(-272,-245)
  106. goto(-275,-227)
  107. end_fill()
  108. #衣服
  109. penup()
  110. goto(-244,-287)
  111. pendown()
  112. begin_fill()
  113. goto(-269,-314)
  114. goto(-310,-405)
  115. goto(-304,-410)
  116. goto(-21,-416)
  117. goto(317,-410)
  118. goto(331,-398)
  119. goto(323,-381)
  120. goto(319,-356)
  121. goto(315,-320)
  122. goto(275,-266)
  123. goto(263,-257)
  124. pensize(15)
  125. pencolor('#c0c0c0')
  126. goto(252,-254)
  127. goto(216,-269)
  128. goto(-13,-353)
  129. pensize(13)
  130. goto(-65,-362)
  131. goto(-109,-356)
  132. pensize(10)
  133. goto(-178,-317)
  134. goto(-214,-296)
  135. goto(-246,-284)
  136. end_fill()
  137. #肩带
  138. penup()
  139. goto(-206,-310)
  140. pendown()
  141. pensize(30)
  142. goto(-183,-363)
  143. goto(-180,-384)
  144. goto(-184,-414)
  145. penup()
  146. goto(229,-285)
  147. pendown()
  148. goto(203,-360)
  149. pensize(34)
  150. goto(190,-415)
  151. penup()
  152. goto(-115,-360)
  153. pendown()
  154. pensize(8)
  155. goto(-96,-411)
  156. goto(-75,-413)
  157. goto(18,-371)
  158. goto(69,-341)
  159. goto(105,-325)
  160. pensize(12)
  161. goto(177,-297)
  162. #中分
  163. pencolor('#808080')
  164. pensize(1)
  165. penup()
  166. goto(67,393)
  167. pendown()
  168. fillcolor('#808080')
  169. begin_fill()
  170. goto(43,+419)
  171. goto(13,+431)
  172. goto(-96,+426)
  173. goto(-156,+402)
  174. goto(-239,+336)
  175. goto(-277,+300)
  176. goto(-307,+263)
  177. goto(-372,+153)
  178. goto(-383,+101)
  179. goto(-373,+57)
  180. goto(-339,+38)
  181. goto(-298,+40)
  182. goto(-278,+61)
  183. goto(-236,+74)
  184. goto(-176,+103)
  185. goto(-163,+128)
  186. goto(-135,+224)
  187. goto(-95,+265)
  188. goto(-64,+271)
  189. goto(-30,+253)
  190. goto(22,+269)
  191. goto(61,268)
  192. goto(75,202)
  193. goto(93,132)
  194. goto(108,71)
  195. goto(136,31)
  196. goto(171,4)
  197. goto(236,-10)
  198. goto(277,-10)
  199. goto(323,-25)
  200. goto(363,-61)
  201. goto(404,-35)
  202. goto(423,14)
  203. goto(453,71)
  204. goto(457,120)
  205. goto(441,170)
  206. goto(398,227)
  207. goto(331,285)
  208. goto(283,323)
  209. goto(232,360)
  210. goto(168,396)
  211. goto(122,416)
  212. goto(87,406)
  213. goto(67,393)
  214. end_fill()
  215. pencolor('black')
  216. pensize(4)
  217. goto(-30,+253)
  218. done()

来做个对比:

        原图:

       画图:

 喜欢的话就给个点赞,收藏,关注吧!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/447237
推荐阅读
相关标签
  

闽ICP备14008679号