先来看下效果图叭。

Py代码:

import turtle as t
#嘤嘤嘤 定义了个小猪佩奇类
class peppaPig:def __init__(self):self.penset()self.nose()self.head()self.ears()self.eyes()self.cheek()self.mouth()self.body()self.hands()self.feet()t.hideturtle()t.exitonclick()def penset(self):t.pensize(4)    #设置画笔大小t.colormode(255) #设置GBK颜色范围t.color((255,155,192),"pink")  #设置画笔颜色和填充色t.speed(10)  #设置画笔速度#鼻子def nose(self):t.pu()  #penup的简写,提笔t.goto(-100,100)  #前往坐标(-100,100)t.pd()  #pendown的简写,下笔t.seth(-30)t.begin_fill()  #外形填充的开始标志a = 0.4for i in range(120):if 0<=i<30 or 60<=i<90:a = a+0.08t.lt(3) #left的简写,向左转3度t.fd(a) #forward的简写,向前走a的步长else:a = a-0.08t.lt(3)t.fd(a)t.end_fill()t.pu()t.seth(90)t.fd(25)t.seth(0)t.fd(10)t.pd()t.color((255,155,192))t.seth(10)t.begin_fill()t.circle(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()  #外形填充的结束标志#头def head(self):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)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.4for 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()#耳朵def ears(self):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()#眼睛def eyes(self):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()#腮def cheek(self):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()#嘴def mouth(self):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)#身体def body(self):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()#手def hands(self):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)#脚def feet(self):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)if __name__ == '__main__':peppaPig()

Python turtle画小猪佩奇相关推荐

  1. 使用python(turtle)画小猪佩奇

    使用python画小猪佩奇 Dear all: 前段时间使用python画小猪佩奇很火.下面我们来一起操作下吧! 操作环境macOS 1.安装Python IDLE ,python的运行环境,可以官网 ...

  2. python实现画小猪佩奇

    python实现画小猪佩奇 import turtle as tt.pensize(4) t.hideturtle() t.colormode(255) t.color((255,155,192),& ...

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

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

  4. python用turtle画小猪佩奇_turtle作图:用turtle画一个小猪佩奇(详解!)

    之前的一篇文章大致说了一下turtle这个模块的基本操作,不知道的朋友可以去看看,真的超级简单:python:turtle作图基础. 准备用turtle来画一个网红猪--小猪佩奇. 在这之前,我们先聊 ...

  5. python turtle 绘图小猪佩奇,Python使用turtle库绘制小猪佩奇(实例代码)

    这篇文章主要介绍了Python使用turtle库绘制小猪佩奇,本文通过实例代码给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下 turtle(海龟)是Python重要的标准库之一,它 ...

  6. Python代码画小猪佩奇--turtle绘图

    Python代码小猪佩奇–turtle绘图 效果图 代码 import time import turtle as tt.pensize(4) # 设置画笔的大小 t.colormode(255) # ...

  7. python turtle 绘图小猪佩奇_python海龟作图完成小猪佩奇

    python海龟作图完成小猪佩奇 来源:常州童程童美少儿编程学校时间:2020/10/12 11:44:59 观察这个图像可以发现,小猪佩奇在构图基本是各种曲线,类抛物线.类圆.类椭圆.类二次贝塞尔曲 ...

  8. python海龟画小猪佩奇动画片全集_用python画个小猪佩奇

    突发奇想,拿python画个小猪佩奇,大家可以运行着玩玩 draw.py # -*- coding:utf-8 -*- from turtle import * def nose(x,y):#鼻子 p ...

  9. 项目报告:turtle画小猪佩奇

    目录 项目: 一.项目思路 二.项目实战 1. 导入模块 2. 创建画布 3. 绘制鼻子 4. 绘制猪头 5. 绘制耳朵 6. 绘制眼睛 7. 绘制脸 8. 绘制嘴 9. 绘制身体 10.绘制手 11 ...

最新文章

  1. Python、Matplot的subplot实现一行3列的子图绘制,并添加背景色
  2. 如何查看和关闭异常SQL进程
  3. 解决编译twrp3.0.3遇到的问题
  4. WebRTC 2021 流行趋势大赏
  5. linux7启动某个服务器,如何在单用户模式下启动RHEL 7 CentOS 7服务器
  6. java数组如何相加_java数组排序,并将数组内的数据求和
  7. 解决TeXstudio外部查看器失败方法
  8. 华为确定2019年目标:超三星成全球最大智能手机供应商
  9. 中国程序员和外国程序员
  10. WebSocket入门使用教程
  11. 卡巴斯基蓝屏解决方案
  12. 微信公众平台开发(110) 微信连Wi-Fi
  13. python多线程之 终止子线程
  14. 双十一在即,阿里的七种武器
  15. Power BI可视化技巧:正负值配色
  16. Android 9.0 设置讯飞语音引擎为默认tts语音播报引擎
  17. 图像处理中常用的彩色模型
  18. Qbo’s concept and design
  19. 【408】计算机统考科目知识整理
  20. 学编程c语言高考能加分吗,学好编程,中高考都能加分,还能保送清华北大!...

热门文章

  1. [转] 关于“时间”的一次探索
  2. Mysql——分组查询
  3. python社区微信群_Python 打造微信群聊天机器人(带操作界面)-Go语言中文社区...
  4. 杨建允:抖快直播电商的运营逻辑是否可以复制
  5. Object类九大方法之notify和notifyAll方法
  6. 微信小程序图片底部留白的问题
  7. 微信公众号开发教程(序)
  8. 写给程序员看的项目管理入门
  9. Bussiness Card Design
  10. 关于photonserver的使用心得