• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python turtle.showturtle函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中turtle.showturtle函数的典型用法代码示例。如果您正苦于以下问题:Python showturtle函数的具体用法?Python showturtle怎么用?Python showturtle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了showturtle函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:BCasaleiro,项目名称:Tic-tac-toe,代码行数:7,代码来源:Galo.py


示例2: show_turtle

def show_turtle(turtle, x):
    """Do you want to see the turtle?"""

    if show_turtle == 'yes':
        turtle.showturtle()
    else:
        turtle.hideturtle()
开发者ID:trarial,项目名称:PythonInteractiveTurtle,代码行数:7,代码来源:TurtleDesignerSecondDraft.py


示例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()
开发者ID:qrdean,项目名称:py,代码行数:26,代码来源:GraphicsAndPatternLibrary.py


示例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
开发者ID:ernestojfcosta,项目名称:IPRP,代码行数:35,代码来源:grelha.py


示例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))
开发者ID:jcowgill,项目名称:cs-work,代码行数:27,代码来源:maze_base.py


示例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)
开发者ID:qrdean,项目名称:py,代码行数:8,代码来源:MyTurtle.py


示例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()
开发者ID:MiniMidgetMichael,项目名称:AI,代码行数:8,代码来源:AI_target.py


示例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()
开发者ID:hmly,项目名称:liang-python,代码行数:9,代码来源:01-18_star.py


示例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)
开发者ID:yj29,项目名称:PythonAssignments,代码行数:10,代码来源:typography.py


示例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()
开发者ID:hmly,项目名称:liang-python,代码行数:11,代码来源:01-16_circles.py


示例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)
开发者ID:qrdean,项目名称:py,代码行数:53,代码来源:GraphicsAndPatternLibrary.py


示例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()
开发者ID:hmly,项目名称:liang-python,代码行数:12,代码来源:03-19_draw-line.py


示例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()
开发者ID:garrettsparks,项目名称:Classwork,代码行数:14,代码来源:main.py


示例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()
开发者ID:rzzzwilson,项目名称:Random-Stuff,代码行数:15,代码来源:test2.py


示例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)
开发者ID:yj29,项目名称:PythonAssignments,代码行数:15,代码来源:forest.py


示例16: circle

 def circle(radius, cx = 0, cy = 0, color = 'black', fill = False, move = True):    
     turtle.showturtle()
     if move == True:
         turtle.penup()
         turtle.goto(cx,cy)
         turtle.pendown()
         turtle.color(color)
         if fill == True:
             turtle.begin_fill()
             turtle.circle(radius)
             turtle.end_fill()
         else:
             turtle.circle(radius)
     turtle.setheading(0)
     turtle.hideturtle()
开发者ID:qrdean,项目名称:py,代码行数:15,代码来源:MyTurtle.py


示例17: main

def main():
    turtle.showturtle()
    turtle.right(108)
    turtle.forward(100)
    turtle.right(216)
    turtle.forward(100)
    turtle.right(216)
    turtle.forward(100)
    turtle.right(216)
    turtle.forward(100)
    turtle.right(198)
    turtle.forward(00)
    turtle.right(18)
    turtle.forward(100)
    turtle.done()
开发者ID:amZotti,项目名称:Python-challenges,代码行数:15,代码来源:1.18.py


示例18: drawStar

def drawStar(location_of_house, max_height, max_height_index, type_of_tree):
    """
    drawStar() position itself where star need to drawn and then draw star
    :param max_height: height of tallest tree
    :param max_height_index:  index of tallest tree
    :return: does not return anything
    """
    t.setposition(-225, 0)
    t.showturtle()
    t.up()

    if max_height_index <= location_of_house:
        for _ in range(1, max_height_index):
            t.forward(100)
    elif max_height_index > location_of_house:
        for _ in range(1, location_of_house):
            t.forward(100)
        t.forward(100)
        for _ in (location_of_house, max_height_index):
            t.forward(100)

    t.left(ANGLENINETY)
    if type_of_tree == 1:
        t.forward(max_height + (25 * math.tan(1.047)) + 35)
    elif type_of_tree == 2:
        t.forward(max_height + (90 / math.pi) + 35)
    elif type_of_tree == 3:
        t.forward(max_height + (30 * math.tan(1.047)) + 35)
    #t.forward(30)

    for _ in range(8):
        t.down()
        t.forward(25)
        t.right(ANGLENINETY * 2)
        t.up()
        t.forward(25)
        t.right(ANGLENINETY * 2)
        t.right((ANGLENINETY * 4) / 8)

    t.right(ANGLENINETY * 2)
    if type_of_tree == 1:
        t.forward(max_height + (25 * math.tan(1.047)) + 75)
    elif type_of_tree == 2:
        t.forward(max_height + (90 / math.pi) + 75)
    elif type_of_tree == 3:
        t.forward(max_height + (30 * math.tan(1.047)) + 75)
    #t.forward(30)
    t.left(ANGLENINETY)
开发者ID:yj29,项目名称:PythonAssignments,代码行数:48,代码来源:forest.py


示例19: init_for_day

def init_for_day():
    """
    Initialize for drawing in the day. (-WINDOW_WIDTH/2, -WINDOW_HEIGHT/2) is in
    the lower left and(WINDOW_WIDTH/2, WINDOW_HEIGHT/2) is in the
    upper right.
    : pre: (relative) pos (0,0), heading (east), up
    : post:(relative) pos (-500,-333.33), heading (east), up
     heading (east), up
    : return: None
    """
    turtle.up()
    turtle.hideturtle()
    turtle.setx(-WINDOW_WIDTH/2)
    turtle.sety(-WINDOW_HEIGHT/3)
    turtle.setheading(0)
    turtle.showturtle()
开发者ID:wish343,项目名称:Python,代码行数:16,代码来源:forest.py


示例20: saveDrawing

def saveDrawing():
    # hide turtle
    turtle.hideturtle()
    # generate unique file name
    dateStr = (datetime.now()).strftime("%d%b%Y-%H%M%S")
    fileName = 'spiro-' + dateStr 
    print('saving drawing to %s.eps/png' % fileName)
    # get tkinter canvas
    canvas = turtle.getcanvas()
    # save postscipt image
    canvas.postscript(file = fileName + '.eps')
    # use PIL to convert to PNG
    img = Image.open(fileName + '.eps')
    img.save(fileName + '.png', 'png')
    # show turtle
    turtle.showturtle()
开发者ID:Unclerojelio,项目名称:python_playground,代码行数:16,代码来源:spiro.py



注:本文中的turtle.showturtle函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python turtle.speed函数代码示例发布时间:2022-05-27
下一篇:
Python turtle.shape函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap