本文整理汇总了Python中turtle.showturtle函数的典型用法代码示例。如果您正苦于以下问题:Python showturtle函数的具体用法?Python showturtle怎么用?Python showturtle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了showturtle函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loop
def loop(x,y):
if -50<x<50 and -5<y<45:
turtle.clear()
play()
else:
turtle.showturtle()
turtle.goto(x, y)
示例2: show_turtle
def show_turtle(turtle, x):
"""Do you want to see the turtle?"""
if show_turtle == 'yes':
turtle.showturtle()
else:
turtle.hideturtle()
示例3: rectangle
def rectangle(length, width, x = 0, y = 0, color = 'black', fill = False):
import turtle
turtle.showturtle()
turtle.penup()
turtle.goto(x,y)
turtle.color(color)
turtle.pendown()
if fill == True:
turtle.begin_fill()
turtle.forward(length)
turtle.left(90)
turtle.forward(width)
turtle.left(90)
turtle.forward(length)
turtle.left(90)
turtle.forward(width)
turtle.end_fill()
else:
turtle.forward(length)
turtle.left(90)
turtle.forward(width)
turtle.left(90)
turtle.forward(length)
turtle.left(90)
turtle.forward(width)
turtle.hideturtle()
示例4: passeio
def passeio(dim, lado, passos):
# Prepara grelha
turtle.speed(0)
grelha_2(dim,lado)
turtle.color('red')
turtle.home()
turtle.pendown()
# Passeio
turtle.speed(6)
turtle.dot()
turtle.showturtle()
lim_x = lim_y = (dim*lado)//2
cor_x = 0
cor_y = 0
for i in range(passos):
vai_para = random.choice(['N','E','S','W'])
if (vai_para == 'N') and (cor_y < lim_y):
cor_y += lado
turtle.setheading(90)
turtle.fd(lado)
elif (vai_para == 'E') and (cor_x < lim_x):
cor_x += lado
turtle.setheading(0)
turtle.fd(lado)
elif (vai_para == 'S') and (cor_y > -lim_y):
cor_y -= lado
turtle.setheading(270)
turtle.fd(lado)
elif (vai_para == 'W') and (cor_x > -lim_x):
cor_x -= lado
turtle.setheading(180)
turtle.fd(lado)
else:
print((vai_para,turtle.xcor(),turtle.ycor()))
continue
示例5: draw_path
def draw_path(self, positions):
'''
Draws the path given by a position list
'''
def position_to_turtle(pos):
'''Converts a maze position to a turtle position'''
return (home_x + _DRAW_SIZE * pos[0], home_y - _DRAW_SIZE * pos[1])
# Get maze size
width, height = self.size
# Prepare turtle
home_x = (-(_DRAW_SIZE * width) / 2) + (_DRAW_SIZE / 2)
home_y = ((_DRAW_SIZE * height) / 2) - (_DRAW_SIZE / 2)
turtle.showturtle()
turtle.pencolor(_DRAW_PATH)
# Move to star
turtle.penup()
turtle.goto(home_x, home_y)
turtle.pendown()
# Draw the path
for pos in positions:
turtle.goto(position_to_turtle(pos))
示例6: writeText
def writeText(x, y, text, color ='black'):
turtle.showturtle()
turtle.color(color)
turtle.penup()
turtle.goto(x + .05*abs(x),y + .05*abs(y))
turtle.pendown()
turtle.write(text)
turtle.setheading(0)
示例7: _goto_coor
def _goto_coor(self):
loc = self.loc
x_cor = self.x_cor
y_cor = self.y_cor
turtle = self.Turtle
turtle.pu()
turtle.goto(x_cor, y_cor)
turtle.showturtle()
示例8: main
def main():
angles = [36, 144, 144, 144, 144]
t.showturtle()
for i in range(5):
t.left(angles[i])
t.forward(300)
t.done()
示例9: init
def init():
turtle.setworldcoordinates(-WINDOW_WIDTH / 2, -WINDOW_WIDTH / 2,
WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2)
turtle.up()
turtle.setheading(0)
turtle.hideturtle()
turtle.title('Snakes')
turtle.showturtle()
turtle.setx(-225)
turtle.speed(0)
示例10: main
def main():
t.showturtle()
pos = [[-45,0], [-45,-90], [45,0], [45,-90]]
for i in range(4):
t.penup()
t.goto(pos[i])
t.pendown()
t.circle(45)
t.done()
示例11: chessboard
def chessboard(side, xstart = 0, ystart = 0, color = 'black', background = 'white'):
import turtle
turtle.speed(50)
turtle.showturtle()
turtle.penup()
turtle.goto(xstart, ystart)
turtle.right(45)
squareSize = side/8
for i in range(1,9):
oddoreven = i % 2
if oddoreven == 1:
for k in range(0,4):
turtle.color(color)
turtle.begin_fill()
turtle.circle(squareSize, steps = 4)
turtle.end_fill()
turtle.left(45)
turtle.forward(squareSize*1.45)
turtle.color(background)
turtle.begin_fill()
turtle.right(45)
turtle.circle(squareSize, steps = 4)
turtle.end_fill()
turtle.left(45)
turtle.forward(squareSize*1.45)
turtle.right(45)
else:
for k in range(0,4):
turtle.color(background)
turtle.begin_fill()
turtle.circle(squareSize, steps = 4)
turtle.end_fill()
turtle.left(45)
turtle.forward(squareSize*1.45)
turtle.color(color)
turtle.begin_fill()
turtle.right(45)
turtle.circle(squareSize, steps = 4)
turtle.end_fill()
turtle.left(45)
turtle.forward(squareSize*1.45)
turtle.right(45)
turtle.penup()
turtle.goto(xstart, ystart+squareSize*1.45*i)
turtle.pendown()
turtle.penup()
turtle.goto(xstart,ystart)
turtle.color('black')
turtle.pensize(5)
turtle.pendown()
turtle.circle(side*1.01, steps = 4)
示例12: drawLine
def drawLine(x1, y1, x2, y2):
turtle.showturtle()
turtle.penup()
# Point 1
turtle.goto(x1, y1)
turtle.pendown()
turtle.write((x1,y1), font=('Calibri', 8))
# Point 2
turtle.goto(x2, y2)
turtle.write((x2,y2), font=('Calibri', 8))
turtle.hideturtle()
turtle.done()
示例13: runSimulation
def runSimulation(path, destination):
turtle.up()
turtle.delay(0)
turtle.setposition(path[0].xloc, path[0].yloc)
for node in path:
turtle.pencolor("red")
turtle.color("green", "orange")
turtle.delay(100)
turtle.showturtle()
turtle.down()
turtle.setposition(node.xloc, node.yloc)
drawRouter(node.label, node.xloc, node.yloc)
turtle.up()
turtle.down()
示例14: parallelogram
def parallelogram(s, color):#creates a single parallelogram
turtle.showturtle()
turtle.shape('turtle')
# time.sleep(3)
turtle.pensize(3)
turtle.fillcolor(color)
turtle.begin_fill()
turtle.fd(s)
turtle.left(45)
turtle.fd(s)
turtle.left(135)
turtle.fd(s)
turtle.left(45)
turtle.fd(s)
turtle.end_fill()
示例15: init
def init():
"""
sets the width of window and initialise parameters
:return:
"""
t.setworldcoordinates(-WINDOW_WIDTH / 2, -WINDOW_WIDTH / 2,
WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2)
t.up()
t.setheading(0)
t.hideturtle()
t.title('Forest')
t.showturtle()
t.setx(-225)
t.speed(0)