2019独角兽企业重金招聘Python工程师标准>>> python学习turtle(龟图标状态)-编程之家

记录学习

turtle.hideturtle()

turtle.ht(),隐藏龟图标

 

turtle.showturtle()

turtle.st(),显示龟图标。

 

turtle.isvisible(),龟是否显示。显示返回true,否则返回false。

 

turtle.shape(name=None),返回或设置形状,最初有以下形状:“arrow”, “turtle”, “circle”, “square”, “triangle”, “classic”。

 

turtle.resizemode(rmode=None),返回或设置龟形状状态

“auto”:调整对应于pensize值的乌龟的外观。跟随pensize变化大小。

“user”:根据stretchfactor和outlinewidth(outline)的值来调整乌龟的外观。shapesize()与参数一起使用时调用resizemode(“user”)

“noresize”:没有改变乌龟的外观。

 

turtle.shapesize(stretch_wid=Nonestretch_len=Noneoutline=None)

turtle.turtlesize(stretch_wid=Nonestretch_len=Noneoutline=None),返回或者设置形状拉伸大小和轮廓线。

stretch_wid是垂直方向拉伸,stretch_len水平方向拉伸,outline轮廓的宽度。

初始形状python学习turtle(龟图标状态)-编程之家

运行,turtle.shapesize(5, 1, 1)

python学习turtle(龟图标状态)-编程之家

python学习turtle(龟图标状态)-编程之家

再运行turtle.shapesize(5, 1, 5)

python学习turtle(龟图标状态)-编程之家

turtle.shearfactor(shear=None),设置或者返回剪力。

python学习turtle(龟图标状态)-编程之家

python学习turtle(龟图标状态)-编程之家

 

python学习turtle(龟图标状态)-编程之家

turtle.tilt(angle),改变龟角度(按当前角度改变),但不改变移动方向。

 

turtle.settiltangle(angle),无论当前是什么角度,重新设置一个指向角度。不改变移动方向。自3.1版开始不推荐使用。

 

turtle.tiltangle(angle=None),返回当前倾斜角度,或重新设置一个指向角度。不改变移动方向。

 

turtle.shapetransform(t11=Nonet12=Nonet21=Nonet22=None),设置或者返回龟形状矩阵数据。

 

turtle.get_shapepoly(),返回当前形状多边形作为坐标对的元组。可用于定义复合形状的新形状。

 

画个太极图;

import turtle as tt.home()
t.bgcolor('#ccc')
##大半圆黑色
t.color('#000')
t.fillcolor('#000')
t.begin_fill()
t.circle(100,180)
t.end_fill()
##大半圆白色
t.color('#fff')
t.fillcolor('#fff')
t.begin_fill()
t.circle(100,180)
t.end_fill()
t.up()
t.sety(100)
##中半圆白色
t.color('#fff')
t.fillcolor('#fff')
t.begin_fill()
t.circle(50,180)
t.end_fill()
t.up()
t.goto(0,0)
##中半圆黑色
t.color('#000')
t.fillcolor('#000')
t.begin_fill()
t.circle(-50,180)
t.end_fill()
##两个小圆
t.up()
t.sety(34)
t.color('#fff')
t.fillcolor('#fff')
t.begin_fill()
t.circle(16,360)
t.end_fill()
t.up()
t.sety(134)
t.color('#000')
t.fillcolor('#000')
t.begin_fill()
t.circle(16,360)
t.end_fill()
t.ht()

如图:

python学习turtle(龟图标状态)-编程之家

转载于:https://my.oschina.net/oisanblog/blog/1982461