
你指的是 Logo 语言么?
命令有点儿多,但大多数是英文单词的头尾字母缩写。
例如:前进是FD(Forward缩写),右转是RT(Right缩写),左转是LT(Left),后退是BK(Back)等等。
当然,最好还是买本书或者参考帮助文件。
海龟画图如何画重合的六边形的方法为:importturtle-as-t-tpensize(3)tspeed("fastest")color["red","blue","green","yellow","black","orange"]whileTrue:tpencolor(color[(i%6)])tforward(i)tleft(360/6),海龟绘图是Python内置的一个比较有趣的模块,模块名称为turtle
#PythonDrawpy
import turtle #导入turtle库
turtlesetup(650, 350, 200, 200) #设置画布大小和位置
turtlepenup() #抬起画笔
turtlefd(-250) #画笔在空中向前飞行-250个像素
turtlependown() #画笔落下
turtlepensize(25) #画笔宽度25个像素
turtlepencolor("purple") #画笔颜色为紫色
turtleseth(-40) #海龟方向香油转动45度,但是不行进
for i in range(4): #这里是一个循环
turtlecircle(40, 80) #绕着左边40远处的点向转80度
turtlecircle(-40, 80) #绕着右边40远处的点向转80度
turtlecircle(40, 80/2) #绕着左边40远处的点向转80/2度
turtlefd(40) #向前40个像素
turtlecircle(16, 180) #绕着左边16远处的点向转180度
turtlefd(40 2/3) #向前402/3个像素
turtledone() #运行完不退出
1turtle库基本介绍
有一只海龟,其在窗体正中心,在画布上游走,走过的轨迹形成了绘制的图形, 海龟由程序控制,可以变换颜色、改变宽度等。
2turtle库绘图窗体布局
不设置位置,默认在屏幕中心显示
3turtle库空间坐标体系
绝对坐标,可以使用goto函数到达指定位置
例如:
4turtle库角度坐标体系
5RGB色彩体系
代码如下
import turtle as t
tspeed(10)
tpensize(1)
tfillcolor('red')
tpencolor('black')
tshape(name='classic')
ttracer(True)
#旗布
print('1旗布')
tpenup()
tleft(135)
tfd(350)
tright(135)
tpendown()
tbegin_fill()
for i in range(2):
tfd(500)
tright(90)
tfd(350)
tright(90)
tend_fill()
#就位
tfd(417)
tpenup()
tright(90)
tfd(30)
tleft(18)
tpendown()
#星1大
print('2大五角星')
tfillcolor('yellow')
tbegin_fill()
for j in range(5):
tfd(40)
tleft(72)
tfd(40)
tright(144)
tend_fill()
#星2小1
print('3小五角星,一')
tright(108)
tpenup()
tfd(85)
tleft(90)
tfd(10)
tpendown()
tleft(18)
tbegin_fill()
for j in range(5):
tfd(10)
tleft(72)
tfd(10)
tright(144)
tend_fill()
tright(18)
#星3小2
print('4小五角星,二')
tpenup()
tfd(50)
tleft(90)
tfd(10)
tright(90)
tpendown()
tleft(18)
tbegin_fill()
for j in range(5):
tfd(10)
tleft(72)
tfd(10)
tright(144)
tend_fill()
tright(18)
#星4小3
print('5小五角星,三')
tpenup()
tfd(50)
tleft(90)
tfd(30) #左右位置
tright(90)
tpendown()
tleft(18)
tbegin_fill()
for j in range(5):
tfd(10)
tleft(72)
tfd(10)
tright(144)
tend_fill()
tright(18)
#星5小4
print('6小五角星,四')
tpenup()
tfd(15)
tleft(90)
tfd(55) #左右位置
tright(90)
tpendown()
tleft(18)
tbegin_fill()
for j in range(5):
tfd(10)
tleft(72)
tfd(10)
tright(144)
tend_fill()
tright(18)
tshape(name='blank')
print('_行程结束_')
tdone()
以上就是关于小海龟作图的具体 *** 作是什么啊全部的内容,包括:小海龟作图的具体 *** 作是什么啊、海龟画图如何画重合的六边形、python绘图工具turtle库的使用等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)