注册 登录
编程论坛 Python论坛

turtle部分函数

东海ECS 发布于 2023-01-29 21:50, 498 次点击
turtle.clear()
清空画布

turtle.bgcolor(colorstr)
设置画笔颜色colorstr:'red','blue','yellow'等

turtle.color(colorstr,fillcolorstr)
和上面那个差不多,这个是画笔和填充颜色一起设置

turtle.pensize(x)
设置画笔的粗细,单位是像素

turtle.write(str, font=('黑体',18))  
写字,用你设置的大小和字体

turtle.mode('logo')
把方向标改成logo模式用mode('standard')切换为标准模式,logo模式初始方向是向上,标准模式初始方向是向右,他们的角度计量是logo=逆时针、标准=顺时针。logo 0=上 90=右 180=下 270=左, 标准 0=右 90=上 180=左 270=下。他们之间的数字是他们之间的方向

turtle.seth(x)
转到x方向

turtle.fd(x)
画笔向前移动x个像素,参数是负的就往后画,也可以用bk函数往后移动

turtle.home()
回到初始位置

turtle.down()
落下画笔

turtle.up()
抬起画笔

turtle.left(x)
是左转x度

turtle.right(x)
右转x度

turtle.goto(x,y)
去某一个坐标

turtle.sety(y)
turtle.setx(x)   
单独控制画笔的x或y

turtle.fillcolor(colorstr)   
设置填充颜色

turtle.color(colorstr,colorstr)
前一个是画笔颜色,后一个是画填充颜色

turtle.begin_fill()
填充准备开始,与end_fill并用

turtle.end_fill()  
在填充准备开始和它之间画的封闭图形都填上颜色

turtle.ht()
隐藏小海龟,也可以用st()来显示小海龟

turtle.shape('turtle')
把画笔形状设成turtle,还有arrow,circle,square,triangle,classic.

turtle.setup(480,360,0,0)
#把窗口的宽设定成480,长=360,显示在屏幕的0y0x也就是左上角

turtle.title(str)
窗口名字设定

turtle.speed(10)
海龟的速度设定

turtle.dot(x)
画一个直径为x的点

turtle.circle(x)
画一个半径为x的圆形

turtle.circle(176,steps=3)
画出一个边长为176像素的正‘3’边形


[此贴子已经被作者于2023-1-31 12:55编辑过]

0 回复
1