当前位置:   article > 正文

Python画动漫人物(2)_用python画动漫人物

用python画动漫人物

文章目录


前言

随着一个个动漫的出现,一个又一个的鲜活的动漫人物纷纷出现,例如:海绵宝宝,派大星,还有

樱桃小丸子等等,我展示的是其中三种:小黄人小猪佩奇和蜘蛛侠。


一、画小黄人

小黄人用椭圆和seth()就能做出来,有些潦草,上代码:

  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. t.begin_fill()
  14. t.forward(200)
  15. t.circle(100, 180)
  16. t.forward(200)
  17. t.circle(100, 180)
  18. t.end_fill()
  19. t.pensize(12)
  20. t.penup()
  21. t.goto(-100, 200)
  22. t.pendown()
  23. t.right(100)
  24. t.circle(500, 23)
  25. t.pensize(3)
  26. t.penup()
  27. t.goto(0, 200)
  28. t.pendown()
  29. t.seth(270)
  30. t.color("black", "white")
  31. t.begin_fill()
  32. t.circle(30)
  33. t.end_fill()
  34. t.penup()
  35. t.goto(15, 200)
  36. t.pendown()
  37. t.color("black", "black")
  38. t.begin_fill()
  39. t.circle(15)
  40. t.end_fill()
  41. t.penup()
  42. t.goto(35, 205)
  43. t.color("black", "white")
  44. t.begin_fill()
  45. t.circle(5)
  46. t.end_fill()
  47. t.pensize(3)
  48. t.penup()
  49. t.goto(0, 200)
  50. t.pendown()
  51. t.seth(90)
  52. t.color("black", "white")
  53. t.begin_fill()
  54. t.circle(30)
  55. t.end_fill()
  56. t.penup()
  57. t.goto(-15, 200)
  58. t.pendown()
  59. t.color("black", "black")
  60. t.begin_fill()
  61. t.circle(15)
  62. t.end_fill()
  63. t.penup()
  64. t.goto(-35, 205)
  65. t.color("black", "white")
  66. t.begin_fill()
  67. t.circle(5)
  68. t.end_fill()
  69. t.penup()
  70. t.goto(-20, 100)
  71. t.pendown()
  72. t.seth(270)
  73. t.color("black", "white")
  74. t.begin_fill()
  75. t.circle(20, 180)
  76. t.left(90)
  77. t.forward(40)
  78. t.end_fill()
  79. t.penup()
  80. t.goto(-100, 0)
  81. t.pendown()
  82. t.seth(0)
  83. t.color("black", "blue")
  84. t.begin_fill()
  85. t.forward(20)
  86. t.left(90)
  87. t.forward(40)
  88. t.right(90)
  89. t.forward(160)
  90. t.right(90)
  91. t.forward(40)
  92. t.left(90)
  93. t.forward(20)
  94. t.seth(270)
  95. t.penup()
  96. t.goto(-100, 0)
  97. t.circle(100, 180)
  98. t.end_fill()
  99. t.penup()
  100. t.goto(-70, 20)
  101. t.pendown()
  102. t.color("black", "blue")
  103. t.begin_fill()
  104. t.seth(45)
  105. t.forward(15)
  106. t.left(90)
  107. t.forward(60)
  108. t.seth(270)
  109. t.forward(15)
  110. t.left(40)
  111. t.forward(50)
  112. t.end_fill()
  113. t.left(180)
  114. t.goto(-70, 30)
  115. t.dot()
  116. t.penup()
  117. t.goto(70, 20)
  118. t.pendown()
  119. t.color("black", "blue")
  120. t.begin_fill()
  121. t.seth(135)
  122. t.forward(15)
  123. t.right(90)
  124. t.forward(60)
  125. t.seth(270)
  126. t.forward(15)
  127. t.right(40)
  128. t.forward(50)
  129. t.end_fill()
  130. t.left(180)
  131. t.goto(70, 30)
  132. t.dot()
  133. t.penup()
  134. t.goto(4, -100)
  135. t.pendown()
  136. t.seth(270)
  137. t.color("black", "black")
  138. t.begin_fill()
  139. t.forward(30)
  140. t.left(90)
  141. t.forward(40)
  142. t.seth(20)
  143. t.circle(10, 180)
  144. t.circle(400, 2)
  145. t.seth(90)
  146. t.forward(20)
  147. t.goto(4, -100)
  148. t.end_fill()
  149. t.penup()
  150. t.goto(-4, -100)
  151. t.pendown()
  152. t.seth(270)
  153. t.color("black", "black")
  154. t.begin_fill()
  155. t.forward(30)
  156. t.right(90)
  157. t.forward(40)
  158. t.seth(20)
  159. t.circle(10, -225)
  160. t.circle(400, -3)
  161. t.seth(90)
  162. t.forward(21)
  163. t.goto(-4, -100)
  164. t.end_fill()
  165. t.penup()
  166. t.goto(-100, 50)
  167. t.pendown()
  168. t.seth(225)
  169. t.color("black", "yellow")
  170. t.begin_fill()
  171. t.forward(40)
  172. t.left(90)
  173. t.forward(35)
  174. t.seth(90)
  175. t.forward(50)
  176. t.end_fill()
  177. t.penup()
  178. t.goto(100, 50)
  179. t.pendown()
  180. t.seth(315)
  181. t.color("black", "yellow")
  182. t.begin_fill()
  183. t.forward(40)
  184. t.right(90)
  185. t.forward(36)
  186. t.seth(90)
  187. t.forward(50)
  188. t.end_fill()
  189. t.penup()
  190. t.goto(0, -100)
  191. t.pendown()
  192. t.forward(30)
  193. t.penup()
  194. t.goto(0, -20)
  195. t.pendown()
  196. t.color("yellow")
  197. t.begin_fill()
  198. t.seth(45)
  199. t.forward(20)
  200. t.circle(10, 180)
  201. t.right(90)
  202. t.circle(10, 180)
  203. t.forward(20)
  204. t.end_fill()
  205. t.penup()
  206. t.color("black")
  207. t.goto(-100, -20)
  208. t.pendown()
  209. t.circle(30, 90)
  210. t.penup()
  211. t.goto(100, -20)
  212. t.pendown()
  213. t.circle(30, -90)
  214. t.penup()
  215. t.goto(2, 300)
  216. t.pendown()
  217. t.begin_fill()
  218. t.seth(135)
  219. t.circle(100, 40)
  220. t.end_fill()
  221. t.penup()
  222. t.goto(2, 300)
  223. t.pendown()
  224. t.begin_fill()
  225. t.seth(45)
  226. t.circle(100, 40)
  227. t.end_fill()

二、画小猪佩奇

小猪佩奇大家都很熟悉,它是由国人阿斯特利(Astley)、贝克(Baker)、戴维斯(Davis)创作、导演和制作的一部英国学前电视动画片,小猪佩奇头用椭圆形,下半身用直线,代码展示:

  1. import turtle as t
  2. t.pensize(4)
  3. t.hideturtle()
  4. t.colormode(255)
  5. t.color((255, 155, 192), "pink")
  6. t.setup(840, 500)
  7. t.speed(10)
  8. #鼻子
  9. t.pu()
  10. t.goto(-100, 100)
  11. t.pd()
  12. t.seth(-30)
  13. t.begin_fill()
  14. a = 0.4
  15. for i in range(120):
  16. if 0 <= i < 30 or 60 <= i < 90:
  17. a = a+0.08
  18. t.lt(3) # 向左转3度
  19. t.fd(a) # 向前走a的步长
  20. else:
  21. a = a-0.08
  22. t.lt(3)
  23. t.fd(a)
  24. t.end_fill()
  25. t.pu()
  26. t.seth(90)
  27. t.fd(25)
  28. t.seth(0)
  29. t.fd(10)
  30. t.pd()
  31. t.pencolor(255, 155, 192)
  32. t.seth(10)
  33. t.begin_fill()
  34. t.circle(5)
  35. t.color(160, 82, 45)
  36. t.end_fill()
  37. t.pu()
  38. t.seth(0)
  39. t.fd(20)
  40. t.pd()
  41. t.pencolor(255, 155, 192)
  42. t.seth(10)
  43. t.begin_fill()
  44. t.circle(5)
  45. t.color(160, 82, 45)
  46. t.end_fill()
  47. #头
  48. t.color((255, 155, 192), "pink")
  49. t.pu()
  50. t.seth(90)
  51. t.fd(41)
  52. t.seth(0)
  53. t.fd(0)
  54. t.pd()
  55. t.begin_fill()
  56. t.seth(180)
  57. t.circle(300, -30)
  58. t.circle(100, -60)
  59. t.circle(80, -100)
  60. t.circle(150, -20)
  61. t.circle(60, -95)
  62. t.seth(161)
  63. t.circle(-300, 15)
  64. t.pu()
  65. t.goto(-100, 100)
  66. t.pd()
  67. t.seth(-30)
  68. a = 0.4
  69. for i in range(60):
  70. if 0 <= i < 30 or 60 <= i < 90:
  71. a = a+0.08
  72. t.lt(3) # 向左转3度
  73. t.fd(a) # 向前走a的步长
  74. else:
  75. a = a-0.08
  76. t.lt(3)
  77. t.fd(a)
  78. t.end_fill()
  79. #耳朵
  80. t.color((255, 155, 192), "pink")
  81. t.pu()
  82. t.seth(90)
  83. t.fd(-7)
  84. t.seth(0)
  85. t.fd(70)
  86. t.pd()
  87. t.begin_fill()
  88. t.seth(100)
  89. t.circle(-50, 50)
  90. t.circle(-10, 120)
  91. t.circle(-50, 54)
  92. t.end_fill()
  93. t.pu()
  94. t.seth(90)
  95. t.fd(-12)
  96. t.seth(0)
  97. t.fd(30)
  98. t.pd()
  99. t.begin_fill()
  100. t.seth(100)
  101. t.circle(-50, 50)
  102. t.circle(-10, 120)
  103. t.circle(-50, 56)
  104. t.end_fill()
  105. #眼睛
  106. t.color((255, 155, 192), "white")
  107. t.pu()
  108. t.seth(90)
  109. t.fd(-20)
  110. t.seth(0)
  111. t.fd(-95)
  112. t.pd()
  113. t.begin_fill()
  114. t.circle(15)
  115. t.end_fill()
  116. t.color("black")
  117. t.pu()
  118. t.seth(90)
  119. t.fd(12)
  120. t.seth(0)
  121. t.fd(-3)
  122. t.pd()
  123. t.begin_fill()
  124. t.circle(3)
  125. t.end_fill()
  126. t.color((255, 155, 192), "white")
  127. t.pu()
  128. t.seth(90)
  129. t.fd(-25)
  130. t.seth(0)
  131. t.fd(40)
  132. t.pd()
  133. t.begin_fill()
  134. t.circle(15)
  135. t.end_fill()
  136. t.color("black")
  137. t.pu()
  138. t.seth(90)
  139. t.fd(12)
  140. t.seth(0)
  141. t.fd(-3)
  142. t.pd()
  143. t.begin_fill()
  144. t.circle(3)
  145. t.end_fill()
  146. #腮
  147. t.color((255, 155, 192))
  148. t.pu()
  149. t.seth(90)
  150. t.fd(-95)
  151. t.seth(0)
  152. t.fd(65)
  153. t.pd()
  154. t.begin_fill()
  155. t.circle(30)
  156. t.end_fill()
  157. #嘴
  158. t.color(239, 69, 19)
  159. t.pu()
  160. t.seth(90)
  161. t.fd(15)
  162. t.seth(0)
  163. t.fd(-100)
  164. t.pd()
  165. t.seth(-80)
  166. t.circle(30, 40)
  167. t.circle(40, 80)
  168. #身体
  169. t.color("red", (255, 99, 71))
  170. t.pu()
  171. t.seth(90)
  172. t.fd(-20)
  173. t.seth(0)
  174. t.fd(-78)
  175. t.pd()
  176. t.begin_fill()
  177. t.seth(-130)
  178. t.circle(100, 10)
  179. t.circle(300, 30)
  180. t.seth(0)
  181. t.fd(230)
  182. t.seth(90)
  183. t.circle(300, 30)
  184. t.circle(100, 3)
  185. t.color((255, 155, 192), (255, 100, 100))
  186. t.seth(-135)
  187. t.circle(-80, 63)
  188. t.circle(-150, 24)
  189. t.end_fill()
  190. #手
  191. t.color((255, 155, 192))
  192. t.pu()
  193. t.seth(90)
  194. t.fd(-40)
  195. t.seth(0)
  196. t.fd(-27)
  197. t.pd()
  198. t.seth(-160)
  199. t.circle(300, 15)
  200. t.pu()
  201. t.seth(90)
  202. t.fd(15)
  203. t.seth(0)
  204. t.fd(0)
  205. t.pd()
  206. t.seth(-10)
  207. t.circle(-20, 90)
  208. t.pu()
  209. t.seth(90)
  210. t.fd(30)
  211. t.seth(0)
  212. t.fd(237)
  213. t.pd()
  214. t.seth(-20)
  215. t.circle(-300, 15)
  216. t.pu()
  217. t.seth(90)
  218. t.fd(20)
  219. t.seth(0)
  220. t.fd(0)
  221. t.pd()
  222. t.seth(-170)
  223. t.circle(20, 90)
  224. #脚
  225. t.pensize(10)
  226. t.color((240, 128, 128))
  227. t.pu()
  228. t.seth(90)
  229. t.fd(-75)
  230. t.seth(0)
  231. t.fd(-180)
  232. t.pd()
  233. t.seth(-90)
  234. t.fd(40)
  235. t.seth(-180)
  236. t.color("black")
  237. t.pensize(15)
  238. t.fd(20)
  239. t.pensize(10)
  240. t.color((240, 128, 128))
  241. t.pu()
  242. t.seth(90)
  243. t.fd(40)
  244. t.seth(0)
  245. t.fd(90)
  246. t.pd()
  247. t.seth(-90)
  248. t.fd(40)
  249. t.seth(-180)
  250. t.color("black")
  251. t.pensize(15)
  252. t.fd(20)
  253. #尾巴
  254. t.pensize(4)
  255. t.color((255, 155, 192))
  256. t.pu()
  257. t.seth(90)
  258. t.fd(70)
  259. t.seth(0)
  260. t.fd(95)
  261. t.pd()
  262. t.seth(0)
  263. t.circle(70, 20)
  264. t.circle(10, 330)
  265. t.circle(70, 30)

三、画蜘蛛侠

蜘蛛侠是漫威漫画里的人物,画这个只需要掌握circle()和画曲线即可,代码:

  1. from turtle import *
  2. bgcolor("#990000")
  3. pensize(10)
  4. penup()
  5. goto(0, 50)
  6. pendown()
  7. circle(-120)
  8. penup()
  9. circle(-120, -60)
  10. pendown()
  11. pensize(5)
  12. right(50)
  13. circle(70, 55)
  14. right(85)
  15. circle(75, 58)
  16. right(90)
  17. circle(70, 55)
  18. right(90)
  19. circle(70, 58)
  20. penup()
  21. pensize(10)
  22. goto(80, 15)
  23. pendown()
  24. seth(92)
  25. fd(135)
  26. seth(125)
  27. circle(30, 135)
  28. seth(190)
  29. fd(50)
  30. seth(125)
  31. circle(30, 135)
  32. seth(275)
  33. fd(90)
  34. penup()
  35. pensize(10)
  36. goto(92, -150)
  37. seth(240)
  38. pendown()
  39. fd(80)
  40. left(10)
  41. circle(-28, 185)
  42. penup()
  43. goto(0, 50)
  44. seth(0)
  45. pensize(10)
  46. circle(-120, -60)
  47. seth(200)
  48. pendown()
  49. fd(72)
  50. left(20)
  51. circle(30, 150)
  52. left(20)
  53. fd(20)
  54. right(15)
  55. fd(10)
  56. pensize(5)
  57. fillcolor("#3366cc")
  58. begin_fill()
  59. seth(92)
  60. circle(-120, 31)
  61. seth(200)
  62. fd(45)
  63. left(90)
  64. fd(52)
  65. end_fill()
  66. fd(-12)
  67. right(90)
  68. fd(40)
  69. penup()
  70. right(90)
  71. fd(18)
  72. pendown()
  73. right(86)
  74. fd(40)
  75. penup()
  76. goto(-152, -86)
  77. pendown()
  78. left(40)
  79. circle(35, 90)
  80. penup()
  81. goto(-80, 116)
  82. seth(10)
  83. pensize(5)
  84. pendown()
  85. begin_fill()
  86. fillcolor("#3366cc")
  87. fd(155)
  88. seth(-88)
  89. fd(37)
  90. seth(195)
  91. fd(156)
  92. end_fill()
  93. penup()
  94. goto(-75, 38)
  95. seth(15)
  96. pendown()
  97. begin_fill()
  98. fd(158)
  99. seth(-88)
  100. fd(55)
  101. seth(140)
  102. circle(120, 78)
  103. end_fill()
  104. penup()
  105. fillcolor("#3366cc")
  106. pensize(5)
  107. goto(75, -170)
  108. pendown()
  109. begin_fill()
  110. seth(240)
  111. fd(30)
  112. right(90)
  113. fd(17)
  114. end_fill()
  115. fd(10)
  116. left(80)
  117. fd(55)
  118. penup()
  119. left(90)
  120. fd(15)
  121. pendown()
  122. left(85)
  123. fd(55)
  124. penup()
  125. goto(43, -225)
  126. left(84)
  127. pendown()
  128. circle(60, 51)
  129. for i in range(3):
  130. penup()
  131. goto(-70+i*15, 135)
  132. seth(-90)
  133. pendown()
  134. pensize(5)
  135. fd(15-2*i)
  136. for i in range(3):
  137. penup()
  138. goto(36 + i * 15, 156)
  139. seth(-90)
  140. pendown()
  141. pensize(5)
  142. fd(15 - 2 * i)
  143. a = -60
  144. b = 70
  145. for i in range(4):
  146. penup()
  147. goto(a, b)
  148. a = a+40
  149. b = b+10
  150. seth(-90)
  151. pendown()
  152. pensize(5)
  153. fd(26)
  154. def oo(li, jing):
  155. penup()
  156. goto(0, 50)
  157. seth(0)
  158. circle(-120, li)
  159. pendown()
  160. right(jing)
  161. pensize(5)
  162. oo(-60, 110)
  163. fd(130)
  164. oo(-28, 96)
  165. fd(140)
  166. oo(9, 89)
  167. fd(144)
  168. oo(42, 70)
  169. fd(160)
  170. oo(80, 60)
  171. fd(130)
  172. penup()
  173. goto(-80, -40)
  174. right(160)
  175. pendown()
  176. right(50)
  177. circle(70, 45)
  178. right(75)
  179. circle(70, 38)
  180. right(50)
  181. circle(70, 45)
  182. right(90)
  183. circle(70, 48)
  184. penup()
  185. goto(-53, -70)
  186. pendown()
  187. left(40)
  188. circle(70, 30)
  189. right(50)
  190. circle(70, 20)
  191. right(50)
  192. circle(70, 38)
  193. right(70)
  194. circle(70, 24)
  195. penup()
  196. goto(-19, -105)
  197. left(72)
  198. pendown()
  199. fd(22)
  200. right(60)
  201. fd(22)
  202. oo(-140, 80)
  203. circle(-90, 120)
  204. penup()
  205. oo(140, 100)
  206. circle(90, 13)
  207. pendown()
  208. right(-50)
  209. circle(70, 45)
  210. right(75)
  211. circle(70, 38)
  212. right(50)
  213. circle(70, 36)
  214. penup()
  215. goto(22, -185)
  216. right(70)
  217. pendown()
  218. fd(72)
  219. penup()
  220. goto(-40, -182)
  221. right(38)
  222. pendown()
  223. fd(70)
  224. penup()
  225. pensize(7)
  226. goto(-15, -110)
  227. seth(0)
  228. pendown()
  229. pensize(10)
  230. begin_fill()
  231. left(130)
  232. fd(110)
  233. right(250)
  234. circle(90, 60)
  235. circle(40, 120)
  236. fillcolor("#F5FFFA")
  237. end_fill()
  238. penup()
  239. goto(5, -110)
  240. pendown()
  241. begin_fill()
  242. right(30)
  243. fd(110)
  244. right(-250)
  245. circle(-90, 60)
  246. circle(-40, 120)
  247. end_fill()
  248. done()

总结:

这些内容,主要用了circle()画圆的方法,画出了小黄人,小猪佩奇和蜘蛛侠这三种形象。

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

闽ICP备14008679号