用Python画小女孩放风筝的示例


Posted in Python onNovember 23, 2019

我就废话不多说了,直接上代码吧!

# coding:utf-8
 2import turtle as t
 3import random
 4# 画心
 5def xin():
 6  def curvemove():
 7    for i in range(200):
 8      t.right(1)
 9      t.forward(0.5)
 10  t.color('red','red')
 11  t.begin_fill()
 12  t.left(140)
 13  t.forward(60)
 14  curvemove()
 15  t.left(120)
 16  curvemove()
 17  t.forward(60)
 18  t.end_fill()
 19# 心里面的十字
 20def shizi():
 21  t.pu()
 22  t.goto(170,285)
 23  t.seth(0)
 24  t.pd()
 25  t.color("black","black")
 26  t.circle(1.5)
 27  t.pensize(2)
 28  t.fd(55)
 29  t.pensize(4)
 30  t.circle(1.5)
 31  t.pu()
 32  t.seth(-90)
 33  t.goto(198,295)
 34  t.seth(-90)
 35  t.pensize(2)
 36  t.pd()
 37  t.fd(65)
 38  t.circle(1.5)
 39  t.circle(160,40)
 40  t.circle(-130,27)
 41  t.circle(-60,40)
 42  t.circle(80,60)
 43# 夹子
 44def jiazi2():
 45  def jiazi(angle):
 46    t.pd()
 47    t.pensize(1)
 48    t.color("black","brown")
 49    t.begin_fill()
 50    t.seth(angle)
 51    t.fd(20)
 52    t.seth(angle-240)
 53    t.fd(10)
 54    t.seth(angle-120)
 55    t.fd(20)
 56    t.seth(angle-240)
 57    t.fd(10)
 58    t.end_fill()
 59    t.pu()
 60  # 画夹子
 61  t.pu()
 62  t.goto(216,180)
 63  jiazi(180)
 64  t.goto(230,150)
 65  jiazi(200)
 66  t.goto(250,125)
 67  jiazi(220)
 68  t.goto(265,95)
 69  jiazi(200)
 70  t.goto(275,55)
 71  jiazi(160)
 72# 人
 73def people():
 74  t.pensize(2)
 75  # 皇冠
 76  def huangguan():
 77    t.pu()
 78    t.goto(-200,0)
 79    t.color("gold","gold")
 80    t.pd()
 81    t.begin_fill()
 82    t.seth(120)
 83    t.fd(32)
 84    t.seth(-120)
 85    t.fd(15)
 86    t.seth(150)
 87    t.fd(10)
 88    t.seth(-120)
 89    t.fd(10)
 90    t.seth(160)
 91    t.fd(15)
 92    t.seth(-60)
 93    t.fd(32)
 94    t.seth(50)
 95    t.circle(-40,60)
 96    t.end_fill()
 97  # 脸
 98  def face():
 99    t.pu()
100    t.goto(-212,-3)
101    t.color("black","white")
102    t.pd()
103    t.circle(-40,150)
104  # 头发
105  def hair():
106    t.pu()
107    t.color("black","black")
108    t.goto(-212, -3)
109    angle = -160
110    for i in range(32):
111      t.pd()
112      angle += 1.4
113      t.seth(angle)
114      t.circle(60, 50)
115      t.fd(random.randint(40,45))
116      t.pu()
117      t.goto(-212, -3)
118    angle = -50
119    for i in range(32):
120      t.pd()
121      angle -= 1.5
122      t.seth(angle)
123      t.circle(-60, 50)
124      t.fd(random.randint(38,40))
125      t.pu()
126      t.goto(-212, -5)
127  # 脖子
128  def nick():
129    t.pu()
130    t.goto(-200,-78)
131    t.pd()
132    t.seth(-90)
133    t.fd(10)
134    t.seth(-45)
135    t.fd(20)
136    t.seth(180)
137    t.fd(30)
138    t.seth(55)
139    t.fd(15)
140    t.circle(10,80)
141  # 下半身
142  def body():
143    t.pu()
144    t.goto(-185,-100)
145    t.seth(-65)
146    t.pd()
147    for i in range(120):
148      t.fd(1.5)
149      t.right(0.1)
150    t.seth(220)
151    t.circle(-130,70)
152    t.seth(75)
153    for i in range(130):
154      t.fd(1.5)
155      t.right(0.06)
156  # 腿
157  def leg():
158    t.pu()
159    t.goto(-220,-300)
160    t.pd()
161    t.seth(-90)
162    t.fd(80)
163    t.pensize(5)
164    t.color("red","red")
165    t.fd(8)
166    t.seth(-30)
167    t.pensize(6)
168    t.color("black","black")
169    t.fd(5)
170    t.pu()
171    t.pensize(2)
172    t.goto(-185,-300)
173    t.pd()
174    t.seth(-90)
175    t.fd(80)
176    t.pensize(5)
177    t.color("red","red")
178    t.fd(8)
179    t.seth(-30)
180    t.pensize(6)
181    t.color("black","black")
182    t.fd(5)
183  huangguan()
184  face()
185  nick()
186  body()
187  leg()
188  hair()
189  # 手
190  t.pu()
191  t.goto(-190,-165)
192  t.pensize(2)
193  t.pd()
194  t.seth(49)
195  t.fd(160)
196  t.circle(-10,80)
197  # 眼睛
198  t.pu()
199  t.goto(-185,-30)
200  t.seth(90)
201  t.pd()
202  t.circle(5,180)
203# 星星
204def star(x,y):
205  color = ["blue","yellow","red","gold","orange","pink","green","purple"]
206  t.pencolor(random.choice(color))
207  t.pu()
208  t.goto(x,y)
209  t.pd()
210  t.seth(90)
211  t.fd(8)
212  t.bk(4)
213  t.seth(0)
214  t.fd(4)
215  t.bk(8)
216  t.fd(4)
217  t.seth(45)
218  t.fd(4)
219  t.bk(8)
220  t.fd(4)
221  t.seth(-45)
222  t.fd(4)
223  t.bk(8)
224if __name__ == "__main__":
225  t.pensize(4) # 设置画笔的大小
226  t.color("black") # 设置画笔颜色和填充颜色(pink)
227  t.setup(650, 800) # 设置主窗口的大小为600*800
228  t.speed(10) # 设置画笔速度为10
229  t.pu()
230  t.goto(200, 220)
231  t.pd()
232  # 心
233  xin()
234  # 十字
235  shizi()
236  # 夹子
237  jiazi2()
238  #线
239  t.pu()
240  t.goto(198,280)
241  t.pd()
242  t.seth(-120)
243  t.circle(-1100,22)
244  t.circle(20,90)
245  t.circle(-30,50)
246  t.circle(15,60)
247  # 人
248  people()
249  # 裙子上的点点
250  star(-230, -200)
251  star(-220, -180)
252  star(-200, -150)
253  star(-180, -288)
254  star(-160, -250)
255  star(-210, -150)
256  star(-210, -140)
257  for i in range(10):
258    star(random.randint(-205,-170),random.randint(-300,-200))
259  # 隐藏画笔
260  t.ht()
261  t.done()

效果如下:

用Python画小女孩放风筝的示例

以上这篇用Python画小女孩放风筝的示例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持三水点靠木。

Python 相关文章推荐
python下调用pytesseract识别某网站验证码的实现方法
Jun 06 Python
浅谈python配置与使用OpenCV踩的一些坑
Apr 02 Python
解决nohup重定向python输出到文件不成功的问题
May 11 Python
ubuntu16.04制作vim和python3的开发环境
Sep 23 Python
Python判断两个文件是否相同与两个文本进行相同项筛选的方法
Mar 01 Python
python,Django实现的淘宝客登录功能示例
Jun 12 Python
python 判断字符串中是否含有汉字或非汉字的实例
Jul 15 Python
pandas read_excel()和to_excel()函数解析
Sep 19 Python
Python Numpy数组扩展repeat和tile使用实例解析
Dec 09 Python
python 操作hive pyhs2方式
Dec 21 Python
python中的unittest框架实例详解
Feb 05 Python
Python机器学习之基于Pytorch实现猫狗分类
Jun 08 Python
python实现对列表中的元素进行倒序打印
Nov 23 #Python
Python实现打印实心和空心菱形
Nov 23 #Python
在Python中使用turtle绘制多个同心圆示例
Nov 23 #Python
python实现画循环圆
Nov 23 #Python
解决python彩色螺旋线绘制引发的问题
Nov 23 #Python
Mac 使用python3的matplot画图不显示的解决
Nov 23 #Python
python 利用turtle模块画出没有角的方格
Nov 23 #Python
You might like
解决File size limit exceeded 错误的方法
2013/06/14 PHP
PHP中VC6、VC9、TS、NTS版本的区别与用法详解
2013/10/26 PHP
php简单中奖算法(实例)
2017/08/15 PHP
PHP PDOStatement::rowCount讲解
2019/02/01 PHP
Chrome中模态对话框showModalDialog返回值问题的解决方法
2010/05/25 Javascript
JQuery拖拽元素改变大小尺寸实现代码
2012/12/10 Javascript
JS高级调试技巧:捕获和分析 JavaScript Error详解
2014/03/16 Javascript
NodeJS Express框架中处理404页面一个方式
2014/05/28 NodeJs
jQuery判断元素上是否绑定了指定事件的方法
2015/03/17 Javascript
JS实现仿新浪黄色经典滑动门效果代码
2015/09/27 Javascript
浅谈JS函数定义方式的区别
2016/10/30 Javascript
使用Bootstrap Tabs选项卡Ajax加载数据实现
2016/12/23 Javascript
Angular2 自定义validators的实现方法
2017/07/05 Javascript
js轮播图的插件化封装详解
2017/07/17 Javascript
vue实现个人信息查看和密码修改功能
2018/05/06 Javascript
微信小程序仿朋友圈发布动态功能
2018/07/15 Javascript
详解原生JS动态添加和删除类
2019/03/26 Javascript
vue+element_ui上传文件,并传递额外参数操作
2020/12/05 Vue.js
[05:13]TI4 中国战队 机场出征!!
2014/07/07 DOTA
Python查看多台服务器进程的脚本分享
2014/06/11 Python
浅谈MySQL中的触发器
2015/05/05 Python
玩转python爬虫之URLError异常处理
2016/02/17 Python
python使用mysql数据库示例代码
2017/05/21 Python
终端命令查看TensorFlow版本号及路径的方法
2018/06/13 Python
python实现逐个读取txt字符并修改
2018/12/24 Python
python实现批处理文件
2020/07/28 Python
基于python实现复制文件并重命名
2020/09/16 Python
CSS3 选择器 基本选择器介绍
2012/01/21 HTML / CSS
学校元旦晚会方案
2014/02/19 职场文书
餐饮业员工工作决心书
2014/03/11 职场文书
小学生志愿者活动方案
2014/08/23 职场文书
学生会竞选演讲稿纪检部
2014/08/25 职场文书
幼师辞职信范文
2015/02/27 职场文书
2015年学校政教处工作总结
2015/05/26 职场文书
建国大业观后感600字
2015/06/01 职场文书
Python实现照片卡通化
2021/12/06 Python