本文整理汇总了Python中turtle.tracer函数的典型用法代码示例。如果您正苦于以下问题:Python tracer函数的具体用法?Python tracer怎么用?Python tracer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tracer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rysuj
def rysuj():
turtle.tracer(0, 0) # wylaczenie animacji co KROK, w celu przyspieszenia
turtle.hideturtle() # ukrycie glowki zolwika
turtle.penup() # podnosimy zolwia, zeby nie mazal nam linii podczas ruchu
ostatnie_rysowanie = 0 # ile kropek temu zostal odrysowany rysunek
for i in xrange(ILE_KROPEK):
# losujemy wierzcholek do ktorego bedziemy zmierzac
do = random.choice(WIERZCHOLKI)
# bierzemy nasza aktualna pozycje
teraz = turtle.position()
# ustawiamy sie w polowie drogi do wierzcholka, ktorego wczesniej obralismy
turtle.setpos(w_polowie_drogi(teraz, do))
# stawiamy kropke w nowym miejscu
turtle.dot(1)
ostatnie_rysowanie += 1
if ostatnie_rysowanie == OKRES_ODSWIEZENIA:
# postawilismy na tyle duzo kropek, zeby odswiezyc rysunek
turtle.update()
ostatnie_rysowanie = 0
pozdrowienia()
turtle.update()
示例2: draw
def draw(self, x, y, width, height, max_length=None, force_fields=None):
"""Draw the string. The grammar-system axiom is extended to
the specified depth"""
self.reset()
turtle.setup(width,height,None,None)
turtle.tracer(200,0)
self.penup()
self.setposition(x,y)
self.origin = x, y
self.max_length = max_length
while not self.grammar_system.done and \
self.grammar_system.generation < self.depth:
self.grammar_system.step()
if (self.max_length is not None and
len(self.grammar_system.string) > self.max_length):
self.hideturtle()
print("Drawing exceeded maximum length")
return False
print(self.grammar_system.string)
if force_fields:
for force_field in force_fields:
self.force_fields.append(Attractor(force_field['type'], force_field['effect'], force_field['x'], force_field['y'], force_field['size']))
non_null = self._draw(self.grammar_system.string, self._rules)
self.hideturtle()
turtle.update()
return non_null
示例3: set
def set(): #set of parameters
turtle.hideturtle()
turtle.tracer(1e3,1)
turtle.left(95)
turtle.penup()
turtle.goto(0,-turtle.window_height()/2)
turtle.pendown()
示例4: draw_maze
def draw_maze():
t.speed(0)
turtle.tracer(10, 25)
t.pensize(3)
t.penup()
t.goto(0, 0)
t.pendown()
t.goto(20 * NC, 0)
t.goto(20 * NC, 20 * NR)
t.goto(0, 20 * NR)
t.goto(0, 0)
for i, ns in enumerate(nodes):
y1, x1 = points[i]
for n in (n for n in ns if n > i):
y2, x2 = points[n]
t.penup()
if n == i + 1:
t.goto(20 * x2, 20 * y1)
t.pendown()
t.goto(20 * x2, 20 * (y1 + 1))
else:
t.goto(20 * x1, 20 * y2)
t.pendown()
t.goto(20 * (x1 + 1), 20 * y2)
示例5: setup
def setup():
turtle.hideturtle()
turtle.tracer(1e3,0)
turtle.left(90)
turtle.penup()
turtle.goto(0,-turtle.window_height()/2)
turtle.pendown()
示例6: __init__
def __init__(self, length=10, angle=90, colors=None, lsystem=None):
import turtle
self.length = length
self.angle = angle
if colors is None:
self.colors = ['red', 'green', 'blue', 'orange', 'yellow', 'brown']
if lsystem is not None:
self.lsystem(lsystem)
# draw number
self.ith_draw = 0
# origin of next draw
self.origin = [0, 0]
# bounding_box
self._box = 0, 0, 0, 0
# turtle head north and positive angles is clockwise
turtle.mode('world')
turtle.setheading(90)
turtle.speed(0) # fastest
turtle.hideturtle()
turtle.tracer(0, 1)
# set pencolor
self.pencolor()
示例7: draw
def draw(self):
super(DragonLSystem, self).draw()
turtle.setup(800,600)
wn = turtle.Screen()
wn.bgcolor('lightblue')
wn.title("Wingled Dragon")
self.turtle = turtle.Turtle()
self.turtle.shape('blank')
turtle.tracer(int(sys.argv[2]),25)
t = self.turtle
t.reset()
t.penup()
t.setpos(-200,0)
t.pendown()
i = 200.0
for c in self.state:
if c == "F":
t.forward(math.ceil(i))
elif c == "+":
t.right(90)
elif c == "-":
t.left(90)
elif c == "C":
i = i/math.sqrt(2)
t.left(45)
wn.exitonclick()
示例8: extension1
def extension1():
turtle.tracer(False)
for i in range(50):
turtle.setheading( random.randint(0,360))
shapelib.parallelogram( random.randint(-350,-250),
random.randint(-300, 300),
random.random(), 'red')
for i in range(50):
turtle.setheading( random.randint(0,360))
shapelib.cross( random.randint(-200, -100),
random.randint(-300, 300),
random.random(), 'yellow')
for i in range(50):
turtle.setheading( random.randint(0,360))
shapelib.star( random.randint(-50, 50),
random.randint(-300, 300),
random.random(), 'pink')
for i in range(50):
turtle.setheading( random.randint(0,360))
shapelib.star( random.randint(100, 200),
random.randint(-300, 300),
random.random(), 'orange')
for i in range(50):
turtle.setheading( random.randint(0,360))
shapelib.cross( random.randint(250, 350),
random.randint(-300, 300),
random.random(), 'green')
for i in range(50):
turtle.setheading( random.randint(0,360))
shapelib.parallelogram( random.randint(400, 500),
random.randint(-300, 300),
random.random(), 'blue')
示例9: skyobjects
def skyobjects( x, y, scale ):
'''puts all of the objects in sky functions togehter'''
t.tracer(False)
star(x-300*scale, y+225*scale, 1*scale, 'True', 'orange')
cloud(x+250*scale, y+200*scale, 1*scale, 'gray')
cloud(x+175*scale, y+125*scale, 0.5*scale, 'gray')
cloud(x+125*scale, y+215*scale, 0.25*scale, 'gray')
示例10: Run
def Run():
#bounds
nearRange = [0, 50]
farRange = [50, 200]
frusHL = 100
#Logic
nearDist = random.uniform(nearRange[0], nearRange[1])
farDist = random.uniform(farRange[0], farRange[1])
d = frusHL * 2
an = nearDist
af = farDist
b = (d*d + af*af - an*an) / (2 * d)
radius = math.sqrt(b*b + an*an)
originY = -frusHL + b
#text.insert('end', 'Origin: %d\n' % originY)
#Render
turtle.clear()
turtle.hideturtle()
turtle.tracer(0, 0)
turtle.penup()
turtle.goto(-farDist, frusHL)
turtle.pendown()
turtle.goto(-nearDist, -frusHL)
turtle.goto(nearDist, -frusHL)
turtle.goto(farDist, frusHL)
turtle.goto(-farDist, frusHL)
turtle.penup()
DrawCircle(0, originY, radius);
turtle.update()
示例11: __init__
def __init__(self, model):
"""Initialize the view at the starting of the application."""
self.model = model
self.cellWidth = self.CELL_WIDTH
self.model = model
self.gridSize = model.GRID_SIZE
self.player = self.model.player1
self.screen = turtle.Screen()
self.gridWidth = self.CELL_WIDTH * self.gridSize
self.playerGrid = self.player.getGrid(self.player.PLAYER_GRID)
self.enemyGrid = self.player.getGrid(self.player.OPPONENT_GRID)
self.iconsToDraw = []
turtle.title('BATTLESHIP : {} vs {}'.format(
self.model.player1.playerName, self.model.player2.playerName))
self.__setScreen()
self.__setColor()
turtle.tracer(0, 0)
gridWidth = self.gridWidth
gridAnchorPoints = []
gridAnchorPoints.append((
-self.width/2 + self.GRID_MARGINLEFT,
self.height/2 - self.GRID_MARGINTOP - gridWidth))
gridAnchorPoints.append((
self.width/2 - gridWidth - self.GRID_MARGINRIGHT,
self.height/2 - self.GRID_MARGINTOP - gridWidth ))
self.__drawGrid(gridAnchorPoints[0], gridWidth)
self.__drawGrid(gridAnchorPoints[1], gridWidth)
self.gridAnchorPoints = gridAnchorPoints
示例12: foliageRight
def foliageRight( x, y, scale):
''' foliage scenery right side of image
use tree() and leaf() functions defined earlier
to make a variety of size and color foliage
using for loops to make multiple'''
t.tracer(False)
for i in range(5):
tree( x+random.randint( 100, 350 )*scale,
y+random.randint( -300, -100 )*scale,
random.randint( 1, 2 )*scale)
for i in range(10):
leaf( x+random.randint( 100, 300 )*scale,
y+random.randint( -300, -100 )*scale,
random.random()*scale,
'red' )
for i in range(10):
leaf( x+random.randint( 100, 300 ),
y+random.randint( -300, -100 ),
random.random()*scale,
'orange' )
for i in range(10):
leaf( x+random.randint( 100, 300 )*scale,
y+random.randint( -300, -100 )*scale,
random.random()*scale,
'yellow' )
示例13: setTurtle
def setTurtle(self):
"""Initializes the turtle object and screen object, while also setting the speed to the maximum"""
self.t = turtle.Turtle()
self.s = turtle.Screen()
self.t.speed(0)
turtle.tracer(0,0)
示例14: setup
def setup():
turtle.hideturtle()
turtle.tracer(1e3,0)
turtle.left(90)
turtle.penup()
turtle.goto(-100,-100)
turtle.pendown()
示例15: tree1
def tree1(argv, x, y):
lsys_filename1 = argv[1]
lsys1 = ls.createLsystemFromFile( lsys_filename1 )
print lsys1
num_iter1 = int( 3 )
dist = float( 5 )
angle1 = float( 22 )
s1 = ls.buildString( lsys1, num_iter1 )
#draw lsystem1
'''this is my first lsystem
with filename mysystem1.txt
with 3 iterations and
with angle = 45 dist = 10'''
turtle.tracer(False)
turtle.speed(50000000)
turtle.up()
turtle.goto(0,0)
turtle.goto(x, y)
turtle.down()
turtle.pencolor('White')
it.drawString( s1, dist, angle1 )
# wait and update
turtle.update()