发布网友 发布时间:2022-04-29 18:28
共1个回答
好二三四 时间:2022-05-22 00:34
整体由四部分组成:红日、小鸟、大小船、水面
from turtle import * #导入turtle setup(1024,700) #画布大小 pensize(3) #笔画大小 speed(0) #笔画速度
#太阳 pu() #抬笔 begin_fill() color("black","red") #黑边,填充为红色 goto(-370,170) pd() #落笔 circle(50) #以半径50画圆 end_fill()
由于小鸟大小一样,这里直接编写函数,后面方便直接调用。
#小鸟 def bird(): left(90) circle(40, 30) circle(20, 120) pu() left(90) forward(45) left(90) pd() circle(-40, 30) circle(-20, 120)
找准位置,调用函数bird
#调用bird color("black") pu() goto(-100,300) pd() bird() pu() left(90) forward(400) sety(200) left(30) pd() bird() right(120) pu() forward(200) right(150) pd() bird() right(120) pu() forward(400) right(160) pd() bird() pu() forward(150) right(110) forward(200) right(150) pd() bird()
#大船 pu() goto(-100,-130) pd() left(40) circle(200,-40) left(57) forward(350) right(100) circle(-100,45) right(30) forward(202) pu() goto(0,-50) pd() right(90) forward(20) right(95) forward(70) right(70) circle(400,-30) right(78) forward(120) left(60) circle(400,30) left(87) forward(120) pu() goto(5,175) pd() left(90) forward(20)
#小船 pu() goto(200,0) pd() right(140) circle(60,40) left(14) forward(70) left(70) forward(20) left(107) forward(115) pu() goto(260,0) pd() right(90) forward(5) right(90) forward(23) left(115) circle(-80,40) left(110) forward(15) right(90) forward(10) backward(10) left(90) forward(12) left(55) circle(80,40) left(80) forward(16)
#水面 #第一条线 pu() goto(-520,-15) pd() left(3) forward(406) pu() forward(178) pd() forward(148) pu() forward(96) pd() forward(200) #第二条线 pu() goto(-475,-50) pd() fd(200) pu() forward(500) pd() forward(250) #第三条线 pu() goto(-400,-80) pd() forward(225) #第四条线 pu() goto(-500,-110) pd() forward(250) #第五条线 pu() goto(-375,-140) pd() forward(200) pu() forward(400) pd() forward(200) #第六条线 pu() goto(-450,-165) pd() forward(200) pu() forward(400) pd() forward(350) #第七条线 pu() goto(-250,-200) pd() forward(100) pu() forward(550) pd() forward(90) #文字 pu() goto(-60,70) write("扬帆起航",font=("宋体",18)) pd() ht() done()
到此这篇关于Python海龟绘图之绘制趣味简笔画的文章就介绍到这了,更多相关Python海龟绘图内容请搜索好二三四以前的文章或继续浏览下面的相关文章希望大家以后多多支持好二三四!
<link rel="stylesheet" href="https://js.how234.com/jslib/syntaxhighlighter/styles/shCore.css" type="text/css" /><link rel="stylesheet" href="https://js.how234.com/jslib/syntaxhighlighter/styles/shThemeDefault.css" type="text/css" /><script type="text/javascript" src="https://js.how234.com/third-party/SyntaxHighlighter/shCore.js"></script><style>pre{overflow-x: auto}</style>