工具使用
开发工具:pycharm
开发环境:python3.7, Windows10
使用工具包:turtle
分析项目思路
1、明确turtle的基本配置。确定画框的高度和画笔的大小,以及相应的画框标题和画笔的运行速度。
screensize(800,600,'white') pensize(3) title('海绵宝宝') speed(19)
2、首先,调整画笔位置,找到相应的原点位置。
defgo_to(x,y): penup() goto(x,y) pendown() go_to(0,0)
3、逐渐画出海绵宝宝的身体部位。
画海绵宝宝的头海绵,选择相应的宽度,可以调整坐标的大小 定位函数可以重复使用,海绵宝宝周围是波浪线,加上相应的弧度和黄色。
defhead(): go_to(-200,180) fillcolor('yellow') begin_fill() seth(-30) for_inrange(6): circle(36,60) circle(-36,60) seth(-125) for_inrange(5): circle(40,60) circle(-40,60) seth(-210) for_inrange(4): circle(45,60) circle(-45,60) seth(65) for_inrange(5): circle(40,60) circle(-40,60) end_fill()
将面部表情添加到海绵宝宝身上,眼睛数据多为圆弧,鼻子小倒钩尺寸可自行调整。
defeye(): #眼白 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基础教程