Python turtle画小猪佩奇
先来看下效果图叭。
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画小猪佩奇相关推荐
- 使用python(turtle)画小猪佩奇
使用python画小猪佩奇 Dear all: 前段时间使用python画小猪佩奇很火.下面我们来一起操作下吧! 操作环境macOS 1.安装Python IDLE ,python的运行环境,可以官网 ...
- python实现画小猪佩奇
python实现画小猪佩奇 import turtle as tt.pensize(4) t.hideturtle() t.colormode(255) t.color((255,155,192),& ...
- 用python画小猪佩奇的编码_如何用Python代码画小猪佩奇
Python语言的功能太强大了,可以制作出很多想想的作品来,不信吗?用Python代码还可以画出小猪佩奇,代码其实很简单的,下面,就将几个关键步骤代码分享出来. 怎么用Python代码画小猪佩奇? 首 ...
- python用turtle画小猪佩奇_turtle作图:用turtle画一个小猪佩奇(详解!)
之前的一篇文章大致说了一下turtle这个模块的基本操作,不知道的朋友可以去看看,真的超级简单:python:turtle作图基础. 准备用turtle来画一个网红猪--小猪佩奇. 在这之前,我们先聊 ...
- python turtle 绘图小猪佩奇,Python使用turtle库绘制小猪佩奇(实例代码)
这篇文章主要介绍了Python使用turtle库绘制小猪佩奇,本文通过实例代码给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下 turtle(海龟)是Python重要的标准库之一,它 ...
- Python代码画小猪佩奇--turtle绘图
Python代码小猪佩奇–turtle绘图 效果图 代码 import time import turtle as tt.pensize(4) # 设置画笔的大小 t.colormode(255) # ...
- python turtle 绘图小猪佩奇_python海龟作图完成小猪佩奇
python海龟作图完成小猪佩奇 来源:常州童程童美少儿编程学校时间:2020/10/12 11:44:59 观察这个图像可以发现,小猪佩奇在构图基本是各种曲线,类抛物线.类圆.类椭圆.类二次贝塞尔曲 ...
- python海龟画小猪佩奇动画片全集_用python画个小猪佩奇
突发奇想,拿python画个小猪佩奇,大家可以运行着玩玩 draw.py # -*- coding:utf-8 -*- from turtle import * def nose(x,y):#鼻子 p ...
- 项目报告:turtle画小猪佩奇
目录 项目: 一.项目思路 二.项目实战 1. 导入模块 2. 创建画布 3. 绘制鼻子 4. 绘制猪头 5. 绘制耳朵 6. 绘制眼睛 7. 绘制脸 8. 绘制嘴 9. 绘制身体 10.绘制手 11 ...
最新文章
- Python、Matplot的subplot实现一行3列的子图绘制,并添加背景色
- 如何查看和关闭异常SQL进程
- 解决编译twrp3.0.3遇到的问题
- WebRTC 2021 流行趋势大赏
- linux7启动某个服务器,如何在单用户模式下启动RHEL 7 CentOS 7服务器
- java数组如何相加_java数组排序,并将数组内的数据求和
- 解决TeXstudio外部查看器失败方法
- 华为确定2019年目标:超三星成全球最大智能手机供应商
- 中国程序员和外国程序员
- WebSocket入门使用教程
- 卡巴斯基蓝屏解决方案
- 微信公众平台开发(110) 微信连Wi-Fi
- python多线程之 终止子线程
- 双十一在即,阿里的七种武器
- Power BI可视化技巧:正负值配色
- Android 9.0 设置讯飞语音引擎为默认tts语音播报引擎
- 图像处理中常用的彩色模型
- Qbo’s concept and design
- 【408】计算机统考科目知识整理
- 学编程c语言高考能加分吗,学好编程,中高考都能加分,还能保送清华北大!...