标签:mic 1.0 star setup tle 大小 sof 基本 引入
import turtle
#setup()设置窗口大小及位置
#setup()可省略
turtle.setup(width,height,startx,starty) turtle.setup(800,800,0,0) turtle.setup(800,800)
#默认采用小数值 可切换为整数值 #1.0:RGB小数值模式 #255:RGB整数值模式 turtle.colormode(mode)
#抬起画笔 turtle.penup() #turtle.pu() #落下画笔 turtle.pendown() #turtle.pd() #画笔宽度 turtle.pensize(width) #turtle.width(width) #画笔颜色 turtle.pencolor(color) #color为颜色字符串或r,g,b值 turtle.pencolor("purlple")#颜色字符串 turtle.pencolor(0.63,0.13,0.94)#RGB的小数值 turtle.pencolor((0.36,0.13,0.94))#RGB的元组值
#将画笔移动到坐标为(x,y)的位置
turtle.goto(x,y)
turtle.goto(100,100)
turtle.goto(0,0)
#向前行进d,d可以为负数 turtle.forward(d)
turtle.fd(d) turtle.fd(100) #向后行进d,d可以为负数
turtle.backword(d) turtle.bk(d) turtle.bk(100) #根据半径r绘制extent角度的弧形 #r:默认圆心在海龟左侧r距离的位置 #extent:绘制角度。默认是360度整圆 turtle.circle(r,extent=None) turtle.circle(100,90)
#seth()改变海龟行进方向 #angle为绝对度数 #seth()只改变方向但不行进 turtle.setheading(angle) turtle.seth(angle) turtle.seth(45) turtle.seth(-135) #海龟向左转 #angle:在当前行进方向上旋转的角度 turtle.left(angle) turtle.left(90) #海龟向右转 turtle.right(angle) turtle.right(90)
#停止画笔绘制,但绘图窗体不关闭 turtle.done()
#八边形绘制 import turtle turtle.pensize(2) for x in range(8): turtle.fd(100) turtle.left(45) turtle.done()
#蟒蛇绘制 import turtle turtle.setup(650,350,200,200) turtle.penup() turtle.fd(-250) turtle.pendown() turtle.pensize(25) turtle.pencolor("purple") turtle.seth(-40) for i in range(4): turtle.circle(40,80) turtle.circle(-40,80) turtle.circle(40,40) turtle.fd(40) turtle.circle(16,180) turtle.fd(40*2/3) turtle.done()
#风车绘制 import turtle turtle.setup(650,650) turtle.penup() turtle.pensize(3) turtle.pencolor("black") turtle.pendown() for x in [0,90,180,270]: turtle.seth(x) turtle.fd(100) turtle.seth(x+90) turtle.circle(100,-45) turtle.goto(0,0) turtle.done()
#叠边形绘制,叠边形内角为80度 import turtle turtle.setup(650,550) turtle.penup() turtle.fd(-100) turtle.pensize(5) turtle.pencolor("black") turtle.pendown() for x in range(9): turtle.fd(100) turtle.left(80) turtle.done()
标签:mic 1.0 star setup tle 大小 sof 基本 引入
原文地址:https://www.cnblogs.com/yxww/p/10629022.html