python用turtle画小猪佩奇_python 用turtle 画小猪佩奇
from turtle import *
def nose(x,y):#鼻子
penup()#提起笔
goto(x,y)#定位
pendown()#落笔,开始画
setheading(-30)#将乌龟的方向设置为to_angle/为数字(0-东、90-北、180-西、270-南)
begin_fill()#准备开始填充图形
a=0.4
for i in range(120):
if 0<=i<30 or 60<=i<90:
a=a+0.08
left(3) #向左转3度
forward(a) #向前走a的步长
else:
a=a-0.08
left(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和fillcolor
end_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.4
for i in range(60):
if 0<=i<30 or 60<=i<90:
a=a+0.08
lt(3) #向左转3度
fd(a) #向前走a的步长
else:
a=a-0.08
lt(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 body(x,y):#身体
color("red",(255,99,71))
penup()
goto(x,y)
pendown()
begin_fill()
setheading(-130)
circle(100,10)
circle(300,30)
setheading(0)
forward(230)
setheading(90)
circle(300,30)
circle(100,3)
color((255,155,192),(255,100,100))
setheading(-135)
circle(-80,63)
circle(-150,24)
end_fill()
def hands(x,y):#手
color((255,155,192))
penup()
goto(x,y)
pendown()
setheading(-160)
circle(300,15)
penup()
setheading(90)
forward(15)
setheading(0)
forward(0)
pendown()
setheading(-10)
circle(-20,90)
penup()
setheading(90)
forward(30)
setheading(0)
forward(237)
pendown()
setheading(-20)
circle(-300,15)
penup()
setheading(90)
forward(20)
setheading(0)
forward(0)
pendown()
setheading(-170)
circle(20,90)
def foot(x,y):#脚
pensize(10)
color((240,128,128))
penup()
goto(x,y)
pendown()
setheading(-90)
forward(40)
setheading(-180)
color("black")
pensize(15)
fd(20)
pensize(10)
color((240,128,128))
penup()
setheading(90)
forward(40)
setheading(0)
forward(90)
pendown()
setheading(-90)
forward(40)
setheading(-180)
color("black")
pensize(15)
fd(20)
def tail(x,y):#尾巴
pensize(4)
color((255,155,192))
penup()
goto(x,y)
pendown()
seth(0)
circle(70,20)
circle(10,330)
circle(70,30)
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) #嘴
body(-32,-8) #身体
hands(-56,-45) #手
foot(2,-177) #脚
tail(148,-155) #尾巴
done()
if __name__ == '__main__':
main()
python用turtle画小猪佩奇_python 用turtle 画小猪佩奇相关推荐
- python turtle画滑稽表情_python使用turtle库绘制奥运五环
python使用turtle库绘制奥运五环 Turtle库是Python语言中一个很流行的绘制图像的函数库,想象一个小乌龟,在一个横轴为x.纵轴为y的坐标系原点,(0,0)位置开始,它根据一组函数指令 ...
- python画五角星代码_Python使用Turtle模块绘制五星红旗代码示例
在Udacity上课时学到了python的turtle方法,这是一个很经典的用来教小孩儿编程的图形模块,最早起源于logo语言.python本身内置了这个模块,其可视化的方法可以帮助小孩儿对编程的一些 ...
- 用python的turtle画正方形内切圆_Python 用turtle实现用正方形画圆的例子
最近发现一个很有意思的画图的python库,叫做turtle,这里先说下用turtle这个库来实现用正方形画圆的思路. 每次都用乌龟(turtle) 来画出一个正方形,然后通过旋转3°后,继续画一样的 ...
- python turtle画中国象棋_python使用turtle绘制国际象棋棋盘
本文实例为大家分享了python使用turtle画国际象棋棋盘的具体代码,供大家参考,具体内容如下 使用的方法是每一个小格每一个小格的画 import turtle for i in range(8) ...
- python画棒棒糖程序_python之turtle简单绘制学习
一.方法 1.forward() | fd():向前移动指定的距离.参数:一个数字(integer or float)). turtle.forward(25) 2.backward() | bk() ...
- python怎么画小海龟_Python 海龟 turtle 画图实战任务(一):让小海龟留下Z字形的足迹以及绘制一个小于号<...
使用 turtle 模块,常规的结束语句 ==> turtle.done()/turtle.mainloop() 示例代码如下: # -*- coding: UTF-8 -*- "&q ...
- python画五角星代码_Python使用turtule画五角星的方法
Python使用turtule画五角星的方法 更新时间:2015年07月09日 10:04:03 作者:pythonstart 这篇文章主要介绍了Python使用turtule画五角星的方法,运行该程 ...
- python代码turtle是什么意思_python中turtle库中的Turtle()是什么,有什么用?
Python的turtle库是一个直观有趣的图形绘制函数库 也是python的标准库之一 下面是我总结的一些turtle库总结 1.画布: (1) turtle.screensize(宽,高,背景颜色 ...
- python turtle库在哪里_Python中turtle库的使用
1.画布 turtle.setup(650,350,200,200) 前两个参数用于说明画布的大小,后两个参数说明窗体的位置 2.画笔设置 语句 用法 turtle.pensize() 用于设置画笔大 ...
- python画棒棒糖程序_Python使用turtle库绘制小猪佩奇(实例代码)
turtle(海龟)是Python重要的标准库之一,它能够进行基本的图形绘制.turtle图形绘制的概念诞生于1969年,成功应用于LOGO编程语言. turtle库绘制图形有一个基本框架:一个小海龟 ...
最新文章
- Java学习总结:32(Runtime类)
- linux 内核参数调整说明
- 深入理解openstack网络架构(2)----Basic Use Cases
- Trie的C++实现及HDU1251,hdu1671
- 数组字典_VBA数组与字典解决方案第1讲:函数,公式,数组,数组公式的概念...
- 论文浅尝 | 基于深度强化学习的远程监督数据集的降噪
- Linux. C语言中else,2. if/else语句
- 苹果华人工程师被捕后续,按“商业间谍”指控,本人不认罪
- 如何在GO语言中使用Kubernetes API?
- 如何使用qtp检查网页中显示的文字颜色为指定的颜色
- 2020 智慧旅游系统总体设计方案
- Oracle 10g 的后台进程
- 三、运算符 | Verilog
- 普通人学python有意义吗_普通人学python有什么用
- CSBJ综述:微生物组数据挖掘方法的挑战与机遇
- 计算机达人成长之路目录
- 解决 ArcGIS Server 10.2.2 无法打开http://localhost:6080/arcgis/manager/
- 关于商商城商品表设计(二)
- Http代理前后的不同之处
- Yolov5 windows下的环境搭建及训练
热门文章
- 如何将u盘两个分区合并?u盘怎么合并一个区
- 激光雷达在自动驾驶中的关键技术应用
- 第四章 Caché JSON 处理数据类型
- 微信小程序网络请求异常怎么办_微信小程序网络超时的处理
- express框架实现文件上传、下载及推送(使用Websocket)
- 如何安装Windows操作系统
- hbase命令使用笔记
- 【对抗攻击论文笔记】Enhancing the Transferability of Adversarial Attacks through Variance Tuning
- Android属于绑定服务特点是,Android P HIDL服务绑定模式与直通模式的分析 (原创)
- Mac下文件Non-ISO extended-ASCII编码问题