侯体宗的博客
  • 首页
  • 人生(杂谈)
  • 技术
  • 关于我
  • 更多分类
    • 文件下载
    • 文字修仙
    • 中国象棋ai
    • 群聊
    • 九宫格抽奖
    • 拼图
    • 消消乐
    • 相册

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

Python  /  管理员 发布于 7年前   217

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

# 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 = -160110    for i in range(32):111      t.pd()112      angle += 1.4113      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 = -50119    for i in range(32):120      t.pd()121      angle -= 1.5122      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*800228  t.speed(10) # 设置画笔速度为10229  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实现对列表中的元素进行倒序打印
  • 昵称:

    邮箱:

    0条评论 (评论内容有缓存机制,请悉知!)
    最新最热
    • 分类目录
    • 人生(杂谈)
    • 技术
    • linux
    • Java
    • php
    • 框架(架构)
    • 前端
    • ThinkPHP
    • 数据库
    • 微信(小程序)
    • Laravel
    • Redis
    • Docker
    • Go
    • swoole
    • Windows
    • Python
    • 苹果(mac/ios)
    • 相关文章
    • 在python语言中Flask框架的学习及简单功能示例(0个评论)
    • 在Python语言中实现GUI全屏倒计时代码示例(0个评论)
    • Python + zipfile库实现zip文件解压自动化脚本示例(0个评论)
    • python爬虫BeautifulSoup快速抓取网站图片(1个评论)
    • vscode 配置 python3开发环境的方法(0个评论)
    • 近期文章
    • 在windows10中升级go版本至1.24后LiteIDE的Ctrl+左击无法跳转问题解决方案(0个评论)
    • 智能合约Solidity学习CryptoZombie第四课:僵尸作战系统(0个评论)
    • 智能合约Solidity学习CryptoZombie第三课:组建僵尸军队(高级Solidity理论)(0个评论)
    • 智能合约Solidity学习CryptoZombie第二课:让你的僵尸猎食(0个评论)
    • 智能合约Solidity学习CryptoZombie第一课:生成一只你的僵尸(0个评论)
    • 在go中实现一个常用的先进先出的缓存淘汰算法示例代码(0个评论)
    • 在go+gin中使用"github.com/skip2/go-qrcode"实现url转二维码功能(0个评论)
    • 在go语言中使用api.geonames.org接口实现根据国际邮政编码获取地址信息功能(1个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf分页文件功能(0个评论)
    • gmail发邮件报错:534 5.7.9 Application-specific password required...解决方案(0个评论)
    • 近期评论
    • 122 在

      学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..
    • 123 在

      Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..
    • 原梓番博客 在

      在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..
    • 博主 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..
    • 1111 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
    • 2016-10
    • 2016-11
    • 2018-04
    • 2020-03
    • 2020-04
    • 2020-05
    • 2020-06
    • 2022-01
    • 2023-07
    • 2023-10
    Top

    Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号 PHP交流群

    侯体宗的博客