最近社会猪真是火得不得了,看到知乎上有人问:你写过或者看过哪些有意思的代码,高赞答主用turtle画了一只佩琪。于是马上跟风画了一只玩玩。

turtle是python中绘制图形的库,还是挺方便的,需要的是耐心。

附上代码,网上也有很多。

#使用turtle画小猪佩琪import turtle as t
t.pensize(4) # 设置画笔的大小
t.colormode(255) # 设置GBK颜色范围为0-255
t.color((255,155,192),"pink") # 设置画笔颜色和填充颜色(pink)
t.setup(840,500) # 设置主窗口的大小为840*500
t.speed(10) # 设置画笔速度为10
#鼻子
t.pu() # 提笔
t.goto(-100,100) # 画笔前往坐标(-100,100)
t.pd() # 下笔
t.seth(-30) # 笔的角度为-30°
t.begin_fill() # 外形填充的开始标志
a=0.4
for i in range(120):if 0<=i<30 or 60<=i<90:a=a+0.08t.lt(3) #向左转3度t.fd(a) #向前走a的步长else:a=a-0.08t.lt(3)t.fd(a)
t.end_fill() # 依据轮廓填充
t.pu() # 提笔
t.seth(90) # 笔的角度为90度
t.fd(25) # 向前移动25
t.seth(0) # 转换画笔的角度为0
t.fd(10)
t.pd()
t.pencolor(255,155,192) # 设置画笔颜色
t.seth(10)
t.begin_fill()
t.circle(5) # 画一个半径为5的圆
t.color(160,82,45) # 设置画笔和填充颜色
t.end_fill()
t.pu()
t.seth(0)
t.fd(20)
t.pd()
t.pencolor(255,155,192)
t.seth(10)
t.begin_fill()
t.circle(5)
t.color(160,82,45)
t.end_fill()
#头
t.color((255,155,192),"pink")
t.pu()
t.seth(90)
t.fd(41)
t.seth(0)
t.fd(0)
t.pd()
t.begin_fill()
t.seth(180)
t.circle(300,-30) # 顺时针画一个半径为300,圆心角为30°的园
t.circle(100,-60)
t.circle(80,-100)
t.circle(150,-20)
t.circle(60,-95)
t.seth(161)
t.circle(-300,15)
t.pu()
t.goto(-100,100)
t.pd()
t.seth(-30)
a=0.4
for i in range(60):if 0<=i<30 or 60<=i<90:a=a+0.08t.lt(3) #向左转3度t.fd(a) #向前走a的步长else:a=a-0.08t.lt(3)t.fd(a)
t.end_fill()
#耳朵
t.color((255,155,192),"pink")
t.pu()
t.seth(90)
t.fd(-7)
t.seth(0)
t.fd(70)
t.pd()
t.begin_fill()
t.seth(100)
t.circle(-50,50)
t.circle(-10,120)
t.circle(-50,54)
t.end_fill()
t.pu()
t.seth(90)
t.fd(-12)
t.seth(0)
t.fd(30)
t.pd()
t.begin_fill()
t.seth(100)
t.circle(-50,50)
t.circle(-10,120)
t.circle(-50,56)
t.end_fill()
#眼睛
t.color((255,155,192),"white")
t.pu()
t.seth(90)
t.fd(-20)
t.seth(0)
t.fd(-95)
t.pd()
t.begin_fill()
t.circle(15)
t.end_fill()
t.color("black")
t.pu()
t.seth(90)
t.fd(12)
t.seth(0)
t.fd(-3)
t.pd()
t.begin_fill()
t.circle(3)
t.end_fill()
t.color((255,155,192),"white")
t.pu()
t.seth(90)
t.fd(-25)
t.seth(0)
t.fd(40)
t.pd()
t.begin_fill()
t.circle(15)
t.end_fill()
t.color("black")
t.pu()
t.seth(90)
t.fd(12)
t.seth(0)
t.fd(-3)
t.pd()
t.begin_fill()
t.circle(3)
t.end_fill()
#腮
t.color((255,155,192))
t.pu()
t.seth(90)
t.fd(-95)
t.seth(0)
t.fd(65)
t.pd()
t.begin_fill()
t.circle(30)
t.end_fill()
#嘴
t.color(239,69,19)
t.pu()
t.seth(90)
t.fd(15)
t.seth(0)
t.fd(-100)
t.pd()
t.seth(-80)
t.circle(30,40)
t.circle(40,80)
#身体
t.color("red",(255,99,71))
t.pu()
t.seth(90)
t.fd(-20)
t.seth(0)
t.fd(-78)
t.pd()
t.begin_fill()
t.seth(-130)
t.circle(100,10)
t.circle(300,30)
t.seth(0)
t.fd(230)
t.seth(90)
t.circle(300,30)
t.circle(100,3)
t.color((255,155,192),(255,100,100))
t.seth(-135)
t.circle(-80,63)
t.circle(-150,24)
t.end_fill()
#手
t.color((255,155,192))
t.pu()
t.seth(90)
t.fd(-40)
t.seth(0)
t.fd(-27)
t.pd()
t.seth(-160)
t.circle(300,15)
t.pu()
t.seth(90)
t.fd(15)
t.seth(0)
t.fd(0)
t.pd()
t.seth(-10)
t.circle(-20,90)
t.pu()
t.seth(90)
t.fd(30)
t.seth(0)
t.fd(237)
t.pd()
t.seth(-20)
t.circle(-300,15)
t.pu()
t.seth(90)
t.fd(20)
t.seth(0)
t.fd(0)
t.pd()
t.seth(-170)
t.circle(20,90)
#脚
t.pensize(10)
t.color((240,128,128))
t.pu()
t.seth(90)
t.fd(-75)
t.seth(0)
t.fd(-180)
t.pd()
t.seth(-90)
t.fd(40)
t.seth(-180)
t.color("black")
t.pensize(15)
t.fd(20)
t.pensize(10)
t.color((240,128,128))
t.pu()
t.seth(90)
t.fd(40)
t.seth(0)
t.fd(90)
t.pd()
t.seth(-90)
t.fd(40)
t.seth(-180)
t.color("black")
t.pensize(15)
t.fd(20)
#尾巴
t.pensize(4)
t.color((255,155,192))
t.pu()
t.seth(90)
t.fd(70)
t.seth(0)
t.fd(95)
t.pd()
t.seth(0)
t.circle(70,20)
t.circle(10,330)
t.circle(70,30)

用python画小猪票佩琪相关推荐

  1. 用python画猪_用python画小猪票佩奇

    加群923414804免费获取数十套PDF资料,助力python学习 turtle是python中绘制图形的库,还是挺方便的,需要的是耐心. 附上代码,网上也有很多. #使用turtle画小猪佩琪 i ...

  2. 用python画佩奇_用python画小猪票佩奇

    加群923414804免费获取数十套PDF资料,助力python学习 turtle是python中绘制图形的库,还是挺方便的,需要的是耐心. 附上代码,网上也有很多. #使用turtle画小猪佩琪 i ...

  3. 用python画小猪佩奇的编码_如何用python绘制小猪佩奇-python绘图教程图文讲解

    原标题:如何用python绘制小猪佩奇-python绘图教程图文讲解 如何运用python来绘制小猪佩奇呢?通过几道简单的python代码即可让你绘制出小猪佩奇,话不多说,直接上代码. 用python ...

  4. 用python画小猪佩奇动画片全集_教你用Python画小猪佩奇

    刚过去几个月大家票圈肯定都被"小猪佩奇"."社会人"等字样刷屏了,不知道啥时候开始小猪佩奇成立社会人的标志,我说不出个所以然.但是相信很多人和我一样没有看过这系 ...

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

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

  6. 用python画小猪佩琪_怎么用python画小猪佩奇

    最近社会猪可是火遍了大江南北,不蹭下热度可对不起它.见过手画的佩奇,见过用代码画的吗? 没有?那就来看我大显身手. 用python的turtle库来画小猪佩奇. 有人问:turtle难不难? 答曰:不 ...

  7. 怎么用python画房子_怎么用python画小猪佩奇

    最近社会猪可是火遍了大江南北,不蹭下热度可对不起它.见过手画的佩奇,见过用代码画的吗? 没有?那就来看我大显身手. 用python的turtle库来画小猪佩奇. 有人问:turtle难不难? 答曰:不 ...

  8. 用Python画小猪佩奇

    最近社会猪可是火遍了大江南北,不蹭下热度可对不起它.见过手画的佩奇,见过用代码画的吗? 没有?那就来看我大显身手. 用python的turtle库来画小猪佩奇. 有人问:turtle难不难? 答曰:不 ...

  9. 用python画小猪佩奇的编码_如何用Python代码画小猪佩奇

    Python语言的功能太强大了,可以制作出很多想想的作品来,不信吗?用Python代码还可以画出小猪佩奇,代码其实很简单的,下面,就将几个关键步骤代码分享出来. 怎么用Python代码画小猪佩奇? 首 ...

最新文章

  1. linux ssh 登录后 空闲断开 解决方法
  2. 计算机408试题2014,2014年考研计算机统考408真题
  3. 分类模型的评估方法-F分数(F-Score)
  4. maven java archetype_使用Maven Archetype创建Java项目模板
  5. [Vuex系列] - Module的用法(终篇)
  6. C和指针之函数之实现简单的printf函数(支持%d, %f, %c, %s)
  7. ASP.NET MVC 入门2、项目的目录结构与核心的DLL
  8. ltsc系统激活_WIN10_X64企业版LTSC 电脑公司装机版 202008
  9. FreeModbus源码获取
  10. 查找某组织下子库存与物料信息
  11. 设置模糊阴影_制作带模糊效果的PPT首页
  12. 斐讯w3固件下载_【2019.11.13更新】斐讯 K3 openwrt固件
  13. 使用java下载东西如何优化下载网速
  14. 概率论与数理统计期末复习(仅供参考)
  15. 为什么要做MSN聊天机器人
  16. 什么软件可以搜C语言题答案,大学c语音搜题app
  17. MySQL 排序规则
  18. 什么电子邮箱最安全,什么邮箱更具私密性?
  19. 如何优化Urchin配置文件每月数据库的磁盘存储空间
  20. 《AlignedReID: Surpassing Human-Level Performance in Person Re-Identification》论文解读

热门文章

  1. uniapp运行时找不到苹果手机
  2. 数百亿级投资催熟NB-IoT 运营商赢利模式未知
  3. c++画蛋糕_为什么Golang能从Java和C++嘴里抢来一块蛋糕
  4. Python 爬虫获取 URP 教务系统学籍信息,你的信息 正暴露在 互联网中!
  5. 摩根大通公布2021年AI研究博士生奖学金名单!获奖华人博士生占1/3
  6. git + sublime text 3配置中遇到的问题
  7. 无套路送 智能摄像机、手环、智能闹钟、护眼台灯
  8. 新的TPM 2.0漏洞可能让黑客窃取加密密钥
  9. 升级Go版本后编译出错:Load redeclared in this block
  10. windows10 启动安卓模拟器会蓝屏的解决方案