python海龟画小猪佩奇动画片全集_用python画个小猪佩奇
突发奇想,拿python画个小猪佩奇,大家可以运行着玩玩
draw.py
# -*- coding:utf-8 -*-
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()
image.png
image.png
image.png
image.png
image.png
python海龟画小猪佩奇动画片全集_用python画个小猪佩奇相关推荐
- python画小猪乔治动画片全集_使用Python海龟画粉红小猪
儿子很喜欢看小猪佩奇,每天都要吆喝几声乔治,乔治,意思就是要看会电视里的小猪佩奇了.于是想到曾看到的用Python海龟模块画的粉红小猪佩奇,于是拿过来稍作整理,跑了一下,恩,效果还真是不错..向原作者 ...
- python代码画小猪佩奇动画片全集_使用python画个小猪佩奇的示例代码
本文给大家较详细的介绍了使用python画个小猪佩奇的示例代码,感兴趣的朋友一起看看吧 基本原理 选好画板大小,设置好画笔颜色.粗细,定位好位置,依次画鼻子.头.耳朵.眼睛.腮.嘴.身体.手脚.尾巴, ...
- python画小猪乔治动画片全集_使用Python的turtle画小猪乔治和哆啦 A 梦!附源码!...
本人是Python新人小白,欢迎各位大佬指正,本文介绍的是用Python的turtle画一只小猪乔治. 还有本人画画基础超级差= =没天赋,画参考度娘上的一个图片画的. 先上总代码,然后说说我写的思路 ...
- 用python画小猪佩奇动画片全集_用python画小猪佩奇(非原创)
略作改动:# coding:utf-8 import turtle as t t.screensize(400, 300, "blue") t.pensize(4) # 设置画笔的 ...
- python画图小猪佩奇动画片全集_用Python画小猪佩奇
使用turtle模块,不同的部位使用不同的函数. # coding:utf-8 from turtle import* def nose(x,y):#鼻子 pu() goto(x,y) pd() se ...
- 用python画小猪佩奇动画片全集_宝宝爱看小猪佩奇,很简单,让我们用python搞定它...
宝宝爱看小猪佩奇,很简单,让我们用python搞定它 现在很多宝宝喜欢看小猪佩奇,今天就教大家用python的海龟画图画一个乖巧萌萌的小猪佩奇,引导对编程产生浓浓 的兴趣. 画图前引导 1.让我们打开 ...
- 用python画小猪佩奇动画片全集_教你用Python画小猪佩奇
刚过去几个月大家票圈肯定都被"小猪佩奇"."社会人"等字样刷屏了,不知道啥时候开始小猪佩奇成立社会人的标志,我说不出个所以然.但是相信很多人和我一样没有看过这系 ...
- python画小猪乔治动画片全集_用python-turtle库画小猪佩奇和乔治
importturtle as t t.pensize(4) t.hideturtle() t.colormode(255) t.color((255,155,192),"pink" ...
- python海龟图 如何控制线的粗细_使用Python中的高级turtle(海龟)作图方法
在Python里,海龟不仅可以画简单的黑线,还可以用它画更复杂的几何图形,用不同的颜色,甚至还可以给形状填色. 一.从基本的正方形开始 引入turtle模块并创建Pen对象: >>> ...
最新文章
- 机器人控制与感知有感
- py文件打包或apk_Python文件打包成exe很简单,如果安卓手机也能运行的软件你会吗...
- Mark一下 | 当当优惠码,实付满150减30 | + 荐书
- Event Delegate(代理)异常:该委托必须有一个目标 解决方法
- c语言更改编译时字体,c习题编译时出现空的字符常量,怎么修改?
- ubuntu12.04编译rtems doc目录
- java碰到乱码如何解决方法_如何处理java的乱码
- 科技公司如何占据了你的每一分钟?
- 在浏览器的地址栏输入网址的背后
- 软考真题答案-2021年11月系统集成项目管理工程师上午题(一)
- table表格固定表头
- 关于数据库时区,这么多奥秘你都知道么?
- 内嵌模式搭建Hive
- RTK计算参数为什么比例必须是0.999或1.000?
- 大唐波斯将军 机器人_波斯帝国被阿拉伯所灭,末代王子三次求助大唐,为何唐朝没有出兵...
- 利润中心的设置与组织架构 绩效考核 财务核算
- java-net-php-python-20jspm健身网站管理计算机毕业设计程序
- windows 7系统安装
- 华为5G模块MH5000-31资料全集5G技术论坛
- YOLO算法改进之结合GradCAM可视化热力图(附详细教程)
热门文章
- 需求治理如何实施(二)
- 在股票技术指标里,EMA和SMA 的区别
- 雨课堂知识点总结(十三)
- 问题解决:虚拟机centos7无法正常启动:XFS (vda3): Corruption of in-memory data detected. Shutting doum filesystem
- python没有英文基础能学吗-我没有英文基础,可以学PYTHON编程么
- External Libraries中有包,但是运行还是找不到xxx程序包
- Java开发手册-1
- 配置Ubuntu 10.04使用飞沃(FEIOW)卡托通过联通3G上网
- 如何查看 ananconda 的环境(虚拟环境)安装包位置
- VB 任意随机数(N-M)的通用函数(单取、多取存入数组、排序等功能) 内附随机数介绍