Python如何绘制海绵宝宝图像
发表于:2024-10-28 作者:千家信息网编辑
千家信息网最后更新 2024年10月28日,这篇文章给大家分享的是有关Python如何绘制海绵宝宝图像的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。工具使用开发工具:pycharm开发环境:python3.7, Wi
千家信息网最后更新 2024年10月28日Python如何绘制海绵宝宝图像
这篇文章给大家分享的是有关Python如何绘制海绵宝宝图像的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
工具使用
开发工具:pycharm
开发环境:python3.7, Windows10
使用工具包:turtle
项目思路解析
1、明确turtle基本配置。在确定画框的高度以及画笔的大小,还有对应画框标题和画笔运行的速度。
screensize(800, 600, 'white') pensize(3) title('海绵宝宝')speed(19)
2、首先调整画笔位置,找到对应原点位置。
def go_to(x, y): penup() goto(x, y) pendown()go_to(0, 0)
3、逐步画出海绵宝宝的身体部件。
画出海绵宝宝的头部海绵,选取对应宽度,坐标大小可自行调整 定位的函数可以重复使用,海绵宝宝周围为波浪线,添加上对应的弧度,添加上黄色。
def head(): go_to(-200, 180) fillcolor('yellow') begin_fill() seth(-30) for _ in range(6): circle(36, 60) circle(-36, 60) seth(-125) for _ in range(5): circle(40,60) circle(-40,60) seth(-210) for _ in range(4): circle(45,60) circle(-45,60) seth(65) for _ in range(5): circle(40,60) circle(-40,60) end_fill()
给海绵宝宝添加上面部表情,眼睛的数据多为圆弧,鼻子为小倒勾尺寸可自行调整。
def eye(): # 眼白 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)def nose(): 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)
面部完成之后开始完善身体的一些结构增加小白衬衫和海绵宝宝的手臂。
def body(): 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()
最后一步给添加海绵宝宝的红色红领巾
def tie(): 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如何绘制海绵宝宝图像"这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
海绵
宝宝
工具
画笔
调整
图像
位置
内容
大小
更多
画框
篇文章
身体
面部
开发
不错
函数
原点
圆弧
坐标
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
深度解析2018上半年网络安全
万方数据库收录论文可评职称吗
高校网络安全建设怎么样
魔兽世界旧版数据库
湖北盛天网络技术旗下云游戏
上海同城爆店码软件开发
涉密网络安全保密考试答题
中国国家社科基金项目数据库
软件开发很忙吗
软件开发是劳动密集型产业吗
计算机网络技术可以做什么职位
服务器cpu处理器
网络安全基本策略
软件开发项目知识产权
网络安全版块实时指数
tv盒子软件开发
软件开发课程总结学习
信息系统网络安全承诺书
网络显示代理服务器拒绝连接
首届深度软件开发大赛
软件开发设置电脑硬件配置
软件开发工具有哪些好听的歌词
服务器如何开启启动项
jsp在线书店数据库
关于注意网络安全的句子
网络管理员维护服务器
网络安全公司业务推广
做软件开发的男生性格特征
构筑网络安全实践
公司云管理服务器