python绘制海绵宝宝,海绵宝宝的python程序代码 |
您所在的位置:网站首页 › 用python画一个海绵宝宝 › python绘制海绵宝宝,海绵宝宝的python程序代码 |
python绘制海绵宝宝,海绵宝宝的python程序代码 工具使用 开发工具:pycharm 开发环境:python3.7,Windows10 使用套件:乌龟 项目思路解析 1.定义乌龟的基本配置。确定框架的高度和画笔的大小,以及对应的框架标题和画笔的运行速度。 屏幕尺寸(800,600,“白色”) 沉思(3) 标题(“海绵宝宝”) 速度(19)2。首先调整画笔位置,找到对应的原点位置。 defgo_to(x,y): 佩努普() 转到(x,y) 彭登() 转到(0,0)3。一步一步画出海绵宝宝的身体部位。 画出海绵宝宝的头部海绵,选择相应的宽度,坐标大小可以自己调整的函数就可以重用了。海绵宝宝周围有波浪线,加上相应的弧度,加上黄色。 defhead(): 转至(-200,180) fillcolor(黄色) begin_fill() 塞思(-30) for_inrange(6): 圆(36,60) 圆(-36,60) 塞思(-125) for_inrange(5): 圆(40,60) 圆(-40,60) 塞思(-210) for_inrange(4): 圆(45,60) 圆(-45,60) 塞思(下)65 for_inrange(5): 圆(40,60) 圆(-40,60) End_fill()为海绵宝宝添加上面部表情。眼睛的数据多为圆弧,鼻子为小倒勾,可以自行调整。 defeye(): (=NationalBureauofStandards)国家标准局 p;#眼白 go_to(14,-5) fillcolor('#f0f0f0') begin_fill() circle(65,360) end_fill() begin_fill() go_to(13,12) seth(98) circle(-65,360) end_fill() #眼球 go_to(-10,20) fillcolor('blue') begin_fill() circle(20,360) end_fill() go_to(-22,20) fillcolor('black') begin_fill() circle(7,360) end_fill() go_to(40,15) fillcolor('blue') begin_fill() circle(-20,360) end_fill() go_to(53,15) fillcolor('black') begin_fill() circle(-7,360) end_fill() #睫毛 go_to(-95,65) left(20) forward(40) go_to(-50,87) right(25) forward(32) go_to(0,70) right(25) forward(40) go_to(40,75) left(35) forward(40) go_to(90,87) right(18) forward(30) go_to(120,70) right(25) forward(40) defnose(): fillcolor('yellow') go_to(0,-7) begin_fill() right(50) circle(-60,30) color('yellow') goto(15,-40) end_fill() color('black') go_to(0,-7) seth(-75) forward(30) go_to(30,-7) seth(-105) 面部完成之后开始完善身体的一些结构增加小白衬衫和海绵宝宝的手臂。 defbody(): go_to(-170,-180) seth(-120) circle(150,30) seth(0) forward(40) seth(100) forward(35) seth(-80) forward(100) fillcolor('brown') begin_fill() seth(0) forward(300) seth(80) forward(110) seth(-100) forward(65) seth(180) forward(315) go_to(-118,-400) end_fill() go_to(-170,-255) fillcolor('yellow') begin_fill() seth(-75) forward(80) seth(0) forward(17) seth(105) forward(85) end_fill() go_to(200,-170) seth(-60) circle(-150,30) seth(-180) forward(45) begin_fill() seth(0) forward(20) seth(-100) forward(85) seth(180) forward(20) end_fill() 最后一步给添加海绵宝宝的红色红领巾 deftie(): go_to(-50,-225) seth(-40) forward(40) seth(30) forward(52) go_to(30,-225) seth(-30) forward(40) seth(40) forward(45) fillcolor('red') go_to(0,-240) begin_fill() seth(-60) forward(10) seth(0) forward(30) seth(60) forward(15) go_to(30,-225) end_fill() go_to(4,-250) begin_fill() seth(-100) forward(80) seth(0) forward(55) seth(100) forward(80) end_fill() 以上就是Python绘图项目之海绵宝宝的画法,希望对大家有所帮助。更多Python学习指路:python基础教程 郑重声明:本文由网友发布,不代表盛行IT的观点,版权归原作者所有,仅为传播更多信息之目的,如有侵权请联系,我们将第一时间修改或删除,多谢。 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |