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)#返回或设置pencolor和fillcolor

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

46 def head(x,y):#头

47 color((255,155,192),"pink")48 penup()49 goto(x,y)50 setheading(0)51 pendown()52 begin_fill()53 setheading(180)54 circle(300,-30)55 circle(100,-60)56 circle(80,-100)57 circle(150,-20)58 circle(60,-95)59 setheading(161)60 circle(-300,15)61 penup()62 goto(-100,100)63 pendown()64 setheading(-30)65 a=0.4

66 for i in range(60):67 if 0<=i<30 or 60<=i<90:68 a=a+0.08

69 lt(3) #向左转3度

70 fd(a) #向前走a的步长

71 else:72 a=a-0.08

73 lt(3)74 fd(a)75 end_fill()76

77

78 def ears(x,y): #耳朵

79 color((255,155,192),"pink")80 penup()81 goto(x,y)82 pendown()83 begin_fill()84 setheading(100)85 circle(-50,50)86 circle(-10,120)87 circle(-50,54)88 end_fill()89

90 penup()91 setheading(90)92 forward(-12)93 setheading(0)94 forward(30)95 pendown()96 begin_fill()97 setheading(100)98 circle(-50,50)99 circle(-10,120)100 circle(-50,56)101 end_fill()102

103

104 def eyes(x,y):#眼睛

105 color((255,155,192),"white")106 penup()107 setheading(90)108 forward(-20)109 setheading(0)110 forward(-95)111 pendown()112 begin_fill()113 circle(15)114 end_fill()115

116 color("black")117 penup()118 setheading(90)119 forward(12)120 setheading(0)121 forward(-3)122 pendown()123 begin_fill()124 circle(3)125 end_fill()126

127 color((255,155,192),"white")128 penup()129 seth(90)130 forward(-25)131 seth(0)132 forward(40)133 pendown()134 begin_fill()135 circle(15)136 end_fill()137

138 color("black")139 penup()140 setheading(90)141 forward(12)142 setheading(0)143 forward(-3)144 pendown()145 begin_fill()146 circle(3)147 end_fill()148

149

150 def cheek(x,y):#腮

151 color((255,155,192))152 penup()153 goto(x,y)154 pendown()155 setheading(0)156 begin_fill()157 circle(30)158 end_fill()159

160

161 def mouth(x,y): #嘴

162 color(239,69,19)163 penup()164 goto(x,y)165 pendown()166 setheading(-80)167 circle(30,40)168 circle(40,80)169

170 def body(x,y):#身体

171 color("red",(255,99,71))172 penup()173 goto(x,y)174 pendown()175 begin_fill()176 setheading(-130)177 circle(100,10)178 circle(300,30)179 setheading(0)180 forward(230)181 setheading(90)182 circle(300,30)183 circle(100,3)184 color((255,155,192),(255,100,100))185 setheading(-135)186 circle(-80,63)187 circle(-150,24)188 end_fill()189

190

191 def hands(x,y):#手

192 color((255,155,192))193 penup()194 goto(x,y)195 pendown()196 setheading(-160)197 circle(300,15)198 penup()199 setheading(90)200 forward(15)201 setheading(0)202 forward(0)203 pendown()204 setheading(-10)205 circle(-20,90)206

207 penup()208 setheading(90)209 forward(30)210 setheading(0)211 forward(237)212 pendown()213 setheading(-20)214 circle(-300,15)215 penup()216 setheading(90)217 forward(20)218 setheading(0)219 forward(0)220 pendown()221 setheading(-170)222 circle(20,90)223

224 def foot(x,y):#脚

225 pensize(10)226 color((240,128,128))227 penup()228 goto(x,y)229 pendown()230 setheading(-90)231 forward(40)232 setheading(-180)233 color("black")234 pensize(15)235 fd(20)236

237 pensize(10)238 color((240,128,128))239 penup()240 setheading(90)241 forward(40)242 setheading(0)243 forward(90)244 pendown()245 setheading(-90)246 forward(40)247 setheading(-180)248 color("black")249 pensize(15)250 fd(20)251

252 def tail(x,y):#尾巴

253 pensize(4)254 color((255,155,192))255 penup()256 goto(x,y)257 pendown()258 seth(0)259 circle(70,20)260 circle(10,330)261 circle(70,30)262

263 def setting(): #参数设置

264 pensize(4)265 hideturtle() #使乌龟无形(隐藏)

266 colormode(255) #将其设置为1.0或255.随后 颜色三元组的r,g,b值必须在0 .. cmode范围内

267 color((255,155,192),"pink")268 setup(840,500)269 speed(10)270

271 defmain():272 setting() #画布、画笔设置

273 nose(-100,100) #鼻子

274 head(-69,167) #头

275 ears(0,160) #耳朵

276 eyes(0,140) #眼睛

277 cheek(80,10) #腮

278 mouth(-20,30) #嘴

279 body(-32,-8) #身体

280 hands(-56,-45) #手

281 foot(2,-177) #脚

282 tail(148,-155) #尾巴

283 done()284

285 if __name__ == '__main__':286 main()

用python turtle画人_Python中如何用turtle库画出小猪佩奇社会人相关推荐

  1. 小猪佩奇python_一段代码画出小猪佩奇社会人 Python

    复制内容到剪贴板 代码:# coding:utf-8 import turtle as t t.pensize(4) t.hideturtle() t.colormode(255) t.color(( ...

  2. python画小猪佩奇视频_用 Python 20 秒画完小猪佩奇“社会人”!附效果视频+完整代码...

    原标题:用 Python 20 秒画完小猪佩奇"社会人"!附效果视频+完整代码 导读:今年社交平台上最火的带货女王是谁?范冰冰?杨幂?Angelababy?不,是猪猪女孩小猪佩奇. ...

  3. 小猪佩奇python_小猪佩奇社会人专用服务器,有意思的python小程序,附python代码...

    最近社会人小猪佩奇挺热门的,大家都在说社会人,那么我们作为IT人,怎么让我们的服务器也蹭一下社会人的热点的?下面来给大家说说. 先来个效果图: 小猪佩奇社会人专用服务器 哈哈,这样是不是挺有意思的?工 ...

  4. 小猪佩奇社会人专用服务器,有意思的python小程序,附python代码

    原文链接:点击打开链接 摘要: 最近社会人小猪佩奇挺热门的,大家都在说社会人,那么我们作为IT人,怎么让我们的服务器也蹭一下社会人的热点的?下面来给大家说说. 先来个效果图: 小猪佩奇社会人专用服务器 ...

  5. python画猪头_使用Python画小猪佩奇 社会人标配

    看了一些用python实现小猪佩奇画画的帖子,向自己实现下,以此记录. 社会人的标配是谁,当然是吹风机小猪佩奇身上纹. 我自己尝试画过小猪配齐但是感觉眼睛特别难画,画出来的猪头没有立体感,眼睛画不好整 ...

  6. python海龟绘图颜色_Python中的高级turtle(海龟)作图(续)

    四.填色 color 函数有三个参数.第一个参数指定有多少红色,第二个指定有多少绿色,第三个指定有多少蓝色.比如,要得到车子的亮红色,我们用 color(1,0,0),也就是让海龟用百分之百的红色画笔 ...

  7. turtle 20秒画完小猪佩奇“社会人”

    转载:https://blog.csdn.net/csdnsevenn/article/details/80650456 图片源自网络 作者 丁彦军 如需转载,请联系原作者授权. 今年社交平台上最火的 ...

  8. Python 20 秒画完小猪佩奇“社会人”!

    每天写代码的程序员,你们知道今年社交平台上最火的带货女王是谁吗?范冰冰?杨幂?Angelababy?不,是猪猪女孩小猪佩奇. 如果你经常用抖音.快手.B 站.知乎.微博--或者类似的任何一个内容或社交 ...

  9. 这个程序员用 Python 20 秒画完小猪佩奇“社会人”!

    点击上方"CSDN",选择"置顶公众号" 关键时刻,第一时间送达! 作者 | 丁彦军 责编 | 唐小引 每天写代码的程序员,你们知道今年社交平台上最火的带货女王 ...

最新文章

  1. android EditText 限定中文个数与英文个数的解决方式
  2. VS Debug必备技能
  3. 干货丨AI语音二三事:你需要了解这些AI 语音对话技术
  4. 学习java时的一些笔记(4)
  5. python好学吗mooc中文网-Python的N种玩法_中国大学MOOC(慕课)
  6. angular接口传参
  7. 安卓能硬改的手机机型_【每日新闻】小米11部分镜头参数爆料;华为重新采购手机零部件 重启4G手机生产...
  8. 【Python】类的基本写法与注释风格
  9. kafka : CommitFailedException already rebalanced and assigned max.poll.records
  10. POJ-2480 Longge's problem 欧拉函数
  11. Atitit   发帖机实现(3 )---usrQBN023 js提交ajax内容到后端规范与标准化
  12. 【T+】余额表联查明细账,提示未将对象引用设置到对象的实例;参数格式错误,solutionID不能为空。
  13. 让RTL8187无线网卡在linux 2.6.28内核支持aircrack-ng注入。
  14. 开启阿里云linux下的pure-ftpd被动模式,解决flashfxp可连接但无法下载的问题
  15. 【问题描述】打印2018年的日历
  16. Python 识别图片文字( Tesseract 安装使用 )
  17. 数据结构与算法分析(C++语言版)_张琨版 第一章课后习题答案
  18. 一文带你全方位了解网卡
  19. STM32单片机和51单片机有何区别?
  20. 【专精特新周报】大禹生物正式登陆北交所;奥迪威、泰德股份获北交所IPO批文;十一部门开展“携手行动” 促进大中小企业融通创新...

热门文章

  1. 嵌入式学习(三)—调试工具J_Link介绍
  2. 红楼梦情感分析matlab,《红楼梦》情感型人格分析
  3. java metrics.counter_Java-Metrics指标度量工具
  4. 一个比较好的Java写的计算器代码
  5. C# 的DateTime的12小时和24小时制
  6. 医院临床护士站、医生站流程图(检验相关)
  7. 京东面试题: 小东抛小球
  8. “最后一问”的高水平提问和雷点,来学习!
  9. 运行于Windows中的GIZA++( GIZA++ working inWindows Platform)
  10. apk 打包 java出错_AndroidApk混淆编译时,报告java.io.IOException...错误解决办法