用python画一只佩奇

  1. from turtle import*
  2.  
  3. def nose(x,y):#鼻子
  4. penup()#提起笔
  5. goto(x,y)#定位
  6. pendown()#落笔,开始画
  7. setheading(-30)#将乌龟的方向设置为to_angle/为数字(0-东、90-北、180-西、270-南)
  8. begin_fill()#准备开始填充图形
  9. a=0.4
  10. for i in range(120):
  11. if 0<=i<30 or 60<=i<90:
  12. a=a+0.08
  13. left(3) #向左转3度
  14. forward(a) #向前走a的步长
  15. else:
  16. a=a-0.08
  17. left(3)
  18. forward(a)
  19. end_fill()#填充完成
  20.  
  21. penup()
  22. setheading(90)
  23. forward(25)
  24. setheading(0)
  25. forward(10)
  26. pendown()
  27. pencolor(255,155,192)#画笔颜色
  28. setheading(10)
  29. begin_fill()
  30. circle(5)
  31. color(160,82,45)#返回或设置pencolorfillcolor
  32. end_fill()
  33.  
  34. penup()
  35. setheading(0)
  36. forward(20)
  37. pendown()
  38. pencolor(255,155,192)
  39. setheading(10)
  40. begin_fill()
  41. circle(5)
  42. color(160,82,45)
  43. end_fill()
  44.  
  45. def head(x,y):#头
  46. color((255,155,192),"pink")
  47. penup()
  48. goto(x,y)
  49. setheading(0)
  50. pendown()
  51. begin_fill()
  52. setheading(180)
  53. circle(300,-30)
  54. circle(100,-60)
  55. circle(80,-100)
  56. circle(150,-20)
  57. circle(60,-95)
  58. setheading(161)
  59. circle(-300,15)
  60. penup()
  61. goto(-100,100)
  62. pendown()
  63. setheading(-30)
  64. a=0.4
  65. for i in range(60):
  66. if 0<=i<30 or 60<=i<90:
  67. a=a+0.08
  68. lt(3) #向左转3度
  69. fd(a) #向前走a的步长
  70. else:
  71. a=a-0.08
  72. lt(3)
  73. fd(a)
  74. end_fill()
  75.  
  76. def ears(x,y): #耳朵
  77. color((255,155,192),"pink")
  78. penup()
  79. goto(x,y)
  80. pendown()
  81. begin_fill()
  82. setheading(100)
  83. circle(-50,50)
  84. circle(-10,120)
  85. circle(-50,54)
  86. end_fill()
  87.  
  88. penup()
  89. setheading(90)
  90. forward(-12)
  91. setheading(0)
  92. forward(30)
  93. pendown()
  94. begin_fill()
  95. setheading(100)
  96. circle(-50,50)
  97. circle(-10,120)
  98. circle(-50,56)
  99. end_fill()
  100.  
  101. def eyes(x,y):#眼睛
  102. color((255,155,192),"white")
  103. penup()
  104. setheading(90)
  105. forward(-20)
  106. setheading(0)
  107. forward(-95)
  108. pendown()
  109. begin_fill()
  110. circle(15)
  111. end_fill()
  112.  
  113. color("black")
  114. penup()
  115. setheading(90)
  116. forward(12)
  117. setheading(0)
  118. forward(-3)
  119. pendown()
  120. begin_fill()
  121. circle(3)
  122. end_fill()
  123.  
  124. color((255,155,192),"white")
  125. penup()
  126. seth(90)
  127. forward(-25)
  128. seth(0)
  129. forward(40)
  130. pendown()
  131. begin_fill()
  132. circle(15)
  133. end_fill()
  134.  
  135. color("black")
  136. penup()
  137. setheading(90)
  138. forward(12)
  139. setheading(0)
  140. forward(-3)
  141. pendown()
  142. begin_fill()
  143. circle(3)
  144. end_fill()
  145.  
  146. def cheek(x,y):#腮
  147. color((255,155,192))
  148. penup()
  149. goto(x,y)
  150. pendown()
  151. setheading(0)
  152. begin_fill()
  153. circle(30)
  154. end_fill()
  155.  
  156. def mouth(x,y): #嘴
  157. color(239,69,19)
  158. penup()
  159. goto(x,y)
  160. pendown()
  161. setheading(-80)
  162. circle(30,40)
  163. circle(40,80)
  164.  
  165. def body(x,y):#身体
  166. color("red",(255,99,71))
  167. penup()
  168. goto(x,y)
  169. pendown()
  170. begin_fill()
  171. setheading(-130)
  172. circle(100,10)
  173. circle(300,30)
  174. setheading(0)
  175. forward(230)
  176. setheading(90)
  177. circle(300,30)
  178. circle(100,3)
  179. color((255,155,192),(255,100,100))
  180. setheading(-135)
  181. circle(-80,63)
  182. circle(-150,24)
  183. end_fill()
  184.  
  185. def hands(x,y):#手
  186. color((255,155,192))
  187. penup()
  188. goto(x,y)
  189. pendown()
  190. setheading(-160)
  191. circle(300,15)
  192. penup()
  193. setheading(90)
  194. forward(15)
  195. setheading(0)
  196. forward(0)
  197. pendown()
  198. setheading(-10)
  199. circle(-20,90)
  200.  
  201. penup()
  202. setheading(90)
  203. forward(30)
  204. setheading(0)
  205. forward(237)
  206. pendown()
  207. setheading(-20)
  208. circle(-300,15)
  209. penup()
  210. setheading(90)
  211. forward(20)
  212. setheading(0)
  213. forward(0)
  214. pendown()
  215. setheading(-170)
  216. circle(20,90)
  217.  
  218. def foot(x,y):#脚
  219. pensize(10)
  220. color((240,128,128))
  221. penup()
  222. goto(x,y)
  223. pendown()
  224. setheading(-90)
  225. forward(40)
  226. setheading(-180)
  227. color("black")
  228. pensize(15)
  229. fd(20)
  230.  
  231. pensize(10)
  232. color((240,128,128))
  233. penup()
  234. setheading(90)
  235. forward(40)
  236. setheading(0)
  237. forward(90)
  238. pendown()
  239. setheading(-90)
  240. forward(40)
  241. setheading(-180)
  242. color("black")
  243. pensize(15)
  244. fd(20)
  245.  
  246. def tail(x,y):#尾巴
  247. pensize(4)
  248. color((255,155,192))
  249. penup()
  250. goto(x,y)
  251. pendown()
  252. seth(0)
  253. circle(70,20)
  254. circle(10,330)
  255. circle(70,30)
  256.  
  257. def setting(): #参数设置
  258. pensize(4)
  259. hideturtle() #使乌龟无形(隐藏)
  260. colormode(255) #将其设置为1.0或255.随后 颜色三元组的r,g,b值必须在0 .. cmode范围内
  261. color((255,155,192),"pink")
  262. setup(840,500)
  263. speed(10)
  264.  
  265. def main():
  266. setting() #画布、画笔设置
  267. nose(-100,100) #鼻子
  268. head(-69,167) #头
  269. ears(0,160) #耳朵
  270. eyes(0,140) #眼睛
  271. cheek(80,10) #腮
  272. mouth(-20,30) #嘴
  273. body(-32,-8) #身体
  274. hands(-56,-45) #手
  275. foot(2,-177) #脚
  276. tail(148,-155) #尾巴
  277. done()
  278.  
  279. if __name__ == '__main__':
  280. main()

python画一只佩奇的更多相关文章

  1. 使用python画一只佩奇

    打开界面: 打开python shell界面. 建立脚本: 单击"file"——"new file"来建立脚本. 编写代码: 具体的代码如下. import t ...

  2. python 画个小猪佩奇

    不知道大家小时候有没有学习过logo语言,就是操纵一只小王八,来画各种图案.博主小学微机课就学习了这个,最近发现python的turtle包就是logo语言,所以画个小猪佩奇和大家分享. 代码来自知乎 ...

  3. python 画小猪佩奇

    转自:python画个小猪佩奇 # -*- coding: utf-8 -*- """ Created on Mon May 20 11:36:03 2019 @auth ...

  4. 沉淀再出发:用python画各种图表

    沉淀再出发:用python画各种图表 一.前言 最近需要用python来做一些统计和画图,因此做一些笔记. 二.python画各种图表 2.1.使用turtle来画图 import turtle as ...

  5. 为什么学Python语言,只需四步全面了解Python语言

    为什么学Python语言,只需四步全面了解Python语言每个时代都会悄悄犒赏会选择的人,Python现在风口的语言Python--第三大主流编程语言Python , 是一种面向对象的解释型计算机程序 ...

  6. python画樱花

    用python画简单的樱花 代码如下: import turtle as T import random import time # 画樱花的躯干(60,t) def Tree(branch, t): ...

  7. 利用Python制作一个只属于和她的聊天器,再也不用担心隐私泄露啦!

    ------------恢复内容开始------------ 是否担心微信的数据流会被监视?是否担心你和ta聊天的小秘密会被保存到某个数据库里?没关系,现在我们可以用Python做一个只属于你和ta的 ...

  8. div+css画一个小猪佩奇

    用DIV+CSS画一个小猪佩奇,挺可爱的,嘻嘻. HTML部分(全是DIV) <!-- 小猪佩奇整体容器 --> <div class="pig_container&quo ...

  9. 用python画 pareto front

    用python画 pareto front 觉得有用的话,欢迎一起讨论相互学习~Follow Me 2D pf import os import matplotlib.pyplot as plt im ...

随机推荐

  1. [转]网络协议-redis协议

    Redis 通信协议(protocol) 本文档翻译自: http://redis.io/topics/protocol . Redis 协议在以下三个目标之间进行折中: 易于实现 可以高效地被计算机 ...

  2. 重大消息:华为笔记本电脑开始用LINUX系统

    对华为而言,此举不失为一个明智的抉择.在手机操作系统领域,目前已被苹果的IOS系统和谷歌的安卓系统垄断.而IOS系统是封闭式,只为苹果手机使用:安卓是开放性,当谷歌与华为停止合作后.华为手机将无法使用 ...

  3. Linux CentOS7 VMware正则介绍、grep工具、egrep表达式

    一.正则介绍 正则是学习shell脚本的必学的内容,正则学的好坏直接影响到shell编程能力. 正则表达式:使用单个字符串来描述或匹配一系列符合某个句法规则的字符串.通常用来检索和替换那些符合某个模式 ...

  4. js网页拉起支付宝支付

    js网页唤起支付宝进行支付 在做uni-app项目中,打包成 ios App的时候,为了绕过苹果支付的审核,所以用的 webview 加载支付宝的网页支付,进行付款 具体实现流程: 前端通过 url ...

  5. Java中Compareable和Comparator两种比较器的区别

    Java中Compareable和Comparator两种比较器的区别 参考原文链接:https://www.cnblogs.com/ldy-blogs/p/8488138.html 1.引言 在ja ...

  6. Logback的AsyncAppender与RollingFileAppender流程解析

    近期工作中涉及到文件记录.文件翻转等操作,思考有没有成熟的代码以便参考. 因此,第一时间就联想到Logback的AsyncAppender以及RollingFileAppender. AsyncApp ...

  7. IOS 常用View属性设置

    设置按钮属性 1.设置按钮背景颜色 backgroundColor @property (weak, nonatomic) IBOutlet UIButton *deleteButton; self. ...

  8. NPM概述及使用简介

    什么是 NPM npm之于Node,就像pip之于Python,gem之于Ruby,composer之于PHP. npm是Node官方提供的包管理工具,他已经成了Node包的标准发布平台,用于Node ...

  9. NO26 Linux的文件权限--chmod--Linux删除文件说明--suid--sgid

    chmod命令改权限:  suid: sgid:

  10. 2.12 学习总结 之 表单校验插件validate

    一.说在前面 昨天 学习了ajax的相关知识 今天 学习表单校验插件validate, 并使用ajax 自定义校验规则 二.validate 插件 1.网络上有许多成熟的插件共使用者参考,插件就是将j ...