本文整理汇总了Python中turtle.Turtle.lt方法的典型用法代码示例。如果您正苦于以下问题:Python Turtle.lt方法的具体用法?Python Turtle.lt怎么用?Python Turtle.lt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类turtle.Turtle
的用法示例。
在下文中一共展示了Turtle.lt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import lt [as 别名]
def main():
## create compound yellow/blue turtleshape for planets
global s
s = Screen()
s.setup(1120,840)
s.reset()
s.tracer(0, 0)
t = Turtle()
t.ht()
t.pu()
t.fd(6)
t.lt(90)
t.begin_poly()
t.circle(6, 180)
t.end_poly()
m1 = t.get_poly()
t.begin_poly()
t.circle(6,180)
t.end_poly()
m2 = t.get_poly()
planetshape = Shape("compound")
planetshape.addcomponent(m1,"orange")
planetshape.addcomponent(m2,"blue")
s.register_shape("planet", planetshape)
#s.tracer(1,0)
s.update()
## setup gravitational system
gs = GravSys()
sun = Star(1000000, Vec(-250,0), Vec(0,-0.35), gs, "circle")
sun.color("yellow")
sun.pensize(1.8)
sun.pu()
earth = Star(5000, Vec(450,0), Vec(0,70), gs, "planet")
earth.pencolor("green")
earth.shapesize(0.8)
rm=12.0583
vm=(8.0*5000/rm)**.5
moon = Star(1, Vec(450+rm,0), Vec(0,70+vm), gs, "planet")
moon.pencolor("blue")
moon.shapesize(0.5)
gs.init()
gs.start()
return "Done!"
示例2: drawLevy
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import lt [as 别名]
def drawLevy(n):
'draws nth Levy curve using instructions obtained from function levy()'
directions = levy(n)
t = Turtle()
bgcolor('black')
t.pencolor('yellow')
t.penup()
t.goto(-300,0)
t.pendown()
t.pensize(2)
for move in directions:
if move == 'F':
t.fd(200/math.sqrt(2)**n)
if move == 'L':
t.lt(45)
if move == 'R':
t.rt(90)
示例3: createPlanetShape
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import lt [as 别名]
def createPlanetShape():
s.tracer(0,0)
t = Turtle()
t.ht()
t.pu()
t.fd(6)
t.lt(90)
t.begin_poly()
t.circle(6, 180)
t.end_poly()
m1 = t.get_poly()
t.begin_poly()
t.circle(6,180)
t.end_poly()
m2 = t.get_poly()
planetshape = Shape("compound")
planetshape.addcomponent(m1,"orange")
planetshape.addcomponent(m2,"blue")
s.register_shape("planet", planetshape)
s.tracer(True,0)
示例4: koch
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import lt [as 别名]
n = 4
def koch(n):
## directions = 'F'
## for i in range(n):
## directions = directions.replace("F","FLFRFLF")
## return directions
if n == 0:
return 'F'
else:
s = koch(n-1)
return s+'L'+s+'R'+s+'L'+s
directions = koch(n)
print('directions: ', directions)
t = Turtle()
bgcolor('black')
t.penup()
t.goto(-300,0)
t.pendown()
t.pencolor('yellow')
t.pensize(3)
for move in directions:
if move == 'F': t.fd(100/2**n)
if move == 'L': t.lt(60)
if move == 'R': t.rt(120)
示例5: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import lt [as 别名]
def main():
s = Turtle()
s.reset()
s.getscreen().tracer(0,0)
s.ht()
s.pu()
s.fd(6)
s.lt(90)
s.begin_poly()
s.circle(6, 180)
s.end_poly()
m1 = s.get_poly()
s.begin_poly()
s.circle(6,180)
s.end_poly()
m2 = s.get_poly()
planetshape = Shape("compound")
planetshape.addcomponent(m1,"orange")
planetshape.addcomponent(m2,"blue")
s.getscreen().register_shape("planet", planetshape)
s.getscreen().tracer(1,0)
## setup gravitational system
gs = GravSys()
sun = Star(1000000, Vec(0,0), Vec(0,-2.5), gs, "circle")
sun.color("yellow")
sun.shapesize(1.8)
sun.pu()
earth = Star(12500, Vec(210,0), Vec(0,195), gs, "planet")
earth.pencolor("green")
earth.shapesize(0.8)
moon = Star(1, Vec(220,0), Vec(0,295), gs, "planet")
moon.pencolor("blue")
moon.shapesize(0.5)
gs.init()
gs.start()
return "Done!"