代码来自CSDN大佬,可直接运行。

通过导入库函数,头、耳朵、鼻子等依次写函数运行绘画。

from turtle import*
def nose(x,y):#鼻子penup()#提起笔goto(x,y)#定位pendown()#落笔,开始画setheading(-30)#将乌龟的方向设置为to_angle/为数字(0-东、90-北、180-西、270-南)begin_fill()#准备开始填充图形a=0.4for i in range(120):if 0<=i<30 or 60<=i<90:a=a+0.08left(3) #向左转3度forward(a) #向前走a的步长else:a=a-0.08left(3)forward(a)end_fill()#填充完成penup()setheading(90)forward(25)setheading(0)forward(10)pendown()pencolor(255,155,192)#画笔颜色setheading(10)begin_fill()circle(5)color(160,82,45)#返回或设置pencolor和fillcolorend_fill()penup()setheading(0)forward(20)pendown()pencolor(255,155,192)setheading(10)begin_fill()circle(5)color(160,82,45)end_fill()
def head(x,y):#头color((255,155,192),"pink")penup()goto(x,y)setheading(0)pendown()begin_fill()setheading(180)circle(300,-30)circle(100,-60)circle(80,-100)circle(150,-20)circle(60,-95)setheading(161)circle(-300,15)penup()goto(-100,100)pendown()setheading(-30)a=0.4for i in range(60):if 0<=i<30 or 60<=i<90:a=a+0.08lt(3) #向左转3度fd(a) #向前走a的步长else:a=a-0.08lt(3)fd(a)end_fill()
def ears(x,y): #耳朵color((255,155,192),"pink")penup()goto(x,y)pendown()begin_fill()setheading(100)circle(-50,50)circle(-10,120)circle(-50,54)end_fill()penup()setheading(90)forward(-12)setheading(0)forward(30)pendown()begin_fill()setheading(100)circle(-50,50)circle(-10,120)circle(-50,56)end_fill()
def eyes(x,y):#眼睛color((255,155,192),"white")penup()setheading(90)forward(-20)setheading(0)forward(-95)pendown()begin_fill()circle(15)end_fill()color("black")penup()setheading(90)forward(12)setheading(0)forward(-3)pendown()begin_fill()circle(3)end_fill()color((255,155,192),"white")penup()seth(90)forward(-25)seth(0)forward(40)pendown()begin_fill()circle(15)end_fill()color("black")penup()setheading(90)forward(12)setheading(0)forward(-3)pendown()begin_fill()circle(3)end_fill()
def cheek(x,y):#腮color((255,155,192))penup()goto(x,y)pendown()setheading(0)begin_fill()circle(30)end_fill()
def mouth(x,y): #嘴color(239,69,19)penup()goto(x,y)pendown()setheading(-80)circle(30,40)circle(40,80)
def setting():          #参数设置pensize(4)hideturtle()        #使乌龟无形(隐藏)colormode(255)      #将其设置为1.0或255.随后 颜色三元组的r,g,b值必须在0 .. cmode范围内color((255,155,192),"pink")setup(840,500)speed(10)
def main():setting()           #画布、画笔设置nose(-100,100)      #鼻子head(-69,167)       #头ears(0,160)         #耳朵eyes(0,140)         #眼睛cheek(80,10)        #腮mouth(-20,30)       #嘴done()
if __name__ == '__main__':main()

绘图过程如下:

Python——啥是佩奇?相关推荐

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

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

  2. python画板——小猪佩奇

    python画板--小猪佩奇 话不多说,直接上源码 # coding:utf-8 import turtle as tt.pensize(4) t.hideturtle() t.colormode(2 ...

  3. python画图小猪佩奇_python 画个小猪佩奇

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

  4. 带你用python利用小猪佩奇制作四个小游戏

    本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理 以下文章来源于腾讯云 作者:Python进阶者 ( 想要学习Python?Pyth ...

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

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

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

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

  7. python画图小猪佩奇_吊炸天!Python 20秒画出小猪佩奇

    原标题:吊炸天!Python 20秒画出小猪佩奇 今年社交平台上的带货女王是谁?范冰冰?杨幂?Angelababy?不,是猪猪女孩小猪佩奇. 小猪佩奇在构图基本是各种曲线,类抛物线.类圆.类椭圆.类二 ...

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

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

  9. 用python绘制小猪佩奇

    程序画是用代码做画,这次画佩奇. 可以用python去绘制小孩子们的喜欢的<海底小纵队>.<BabyShark>.<超级飞侠>.<汪汪队>等动画片的人物 ...

  10. 用Python画小猪佩奇

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

最新文章

  1. Chromosome-scale assemblies of plant genomes using nanopore long reads and optical maps
  2. [Wordpress]wp_dropdown_categories() 添加自定义的attribute(属性)
  3. opencv-视频处理-实时的前景检测-Vibe算法
  4. python对字符串和集合的内存垃圾回收机制
  5. 如何识别南孚电池是号码
  6. 前端性能优化-减少HTTP请求数
  7. H.264编码profile level控制
  8. webpack 4.0 学习笔记(一)
  9. 【Java从0到架构师】SpringBoot - 入门_配置文件_YAML
  10. C#刨根究底:《你必须知道的.NET》读书笔记系列
  11. linux windows拷贝文件,把linux上的文件拷贝到windows下
  12. 如何在服务器上运行python,如何在网络服务器上运行Python脚本
  13. java反射机制和运用
  14. 3GPP 5GNR 物理层协议梳理
  15. 我教女朋友学编程Html系列(6)—Html常用表单控件
  16. aliases节点解析
  17. python获取小图在大图中的坐标和相似度
  18. 在手机上编程:自制的小飞可编程复数计算器(小飞计算器)
  19. BaiduMapTileCutter切百度地图瓦片
  20. Nubia Z5S(高通公司MSM8974) QHSUSB_BULK砖的方法节省模式(随着win7在恢复recovery分区案例)...

热门文章

  1. 在moss上自己总结了点小经验。。高手可以飘过 转贴
  2. android 文字尺寸(宽高)的测量
  3. tensorflow保存和加载npy文件
  4. 操盘手给你讲市场理念
  5. grafana - 监控信息可视化工具
  6. opencv--python(一)图像和视频处理之读取,显示和保存
  7. 百度地图实时路况数据爬取
  8. 华为电脑如何下载python_windows下如何安装Python、pandas
  9. 如何在QQ空间中使用背景图片
  10. 基于java(springboot)酒店民宿客房管理系统源码成品(java毕业设计)