Python turtle库

 turtle.setup(width,height,startx,starty)

 此函数用来设置窗口的大小及位置

其中 startx,starty两个可选可不选,不选的话默认会在屏幕的正中间。

startx,starty是以屏幕左上角为原点建立的坐标系中的位置。

width,height是窗口的宽度和高度。

turtle.goto(x,y)

去以窗口建立的直角坐标系的x,y位置。

turtle.bk(d) 画笔前进d像素

tutle.fd(d) 画笔后退d像素

turtle.seth(angle) 画笔旋转angle度,改变画笔的行进方向,但是不行进

turtle.left(angle)/right(angle) 画笔向左/向右angle角度

turtle.colormode(mode) 设置RGB的模式

(1) 1.0-RGB小数值模式

(2) 255-RGB整数模式

turtle.circle(r,angle): 根据半径r绘制angle角度的弧形,r默认圆心在画笔左侧r距离的位置 

turtle.penup() 抬起画笔,海龟在飞行   别名 turtle.pu()

turtle.pendown() 落下画笔,海龟在爬行  别名 turtle.pd()

turtle.pensize(width) 画笔宽度,海龟腰围   别名 turtle.width(width)

turtle.pencolor(color) color为颜色字符串或r,g,b的值,画笔颜色,海龟在涂装

(1) 颜色字符串 turtle.pencolor("red")

(2) RGB 的小数值 turtle.pencolor(0.63,0.13,0.94)

(3)RGB 的元组值 turtle.pencolor((0.63,0.13,0.94))

turtle.done(手动退出)

猜你喜欢

转载自blog.csdn.net/qq_41410799/article/details/83386992