当前位置: 首页>>代码示例>>Python>>正文


Python turtle.reset函数代码示例

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


在下文中一共展示了reset函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: drawCloud

def drawCloud(words, num = 20):
    """ Draws a wordcloud with 20 random words, sized by frequency found in 
    the WORDS dictionary. """
    t.reset()
    t.up()
    t.hideturtle()
    topCounts = sorted([words[word] for word in list(words.keys()) if len(word) > 3])
    largest = topCounts[0]
    normalized_counts = {}
    for item in list(words.keys()):
        if len(item) > 3:
            newSize = int(float(words[item]) / largest * 24)
            normalized_counts[item] = newSize
    
    size = t.screensize()
    width_dim = (int(-1 * size[0] / 1.5), int(size[0] / 2))
    height_dim = (int(-1 * size[1] / 1.5), int(size[1] / 1.5))
    

    for item in random.sample(list(normalized_counts.keys()), num):
        t.goto(random.randint(*width_dim), random.randint(*height_dim))
        t.color(random.choice(COLORS))
        try:
            t.write(item, font = ("Arial", int(normalized_counts[item]), "normal"))
        except:
            try:
                t.write(str(item, errors = 'ignore'), font = ("Arial", int(normalized_counts[item]), "normal"))
            except:
                pass
开发者ID:cs10,项目名称:twitter,代码行数:29,代码来源:wordcloud.py

示例2: initBannerCanvas

def initBannerCanvas( numChars , numLines, scale ):
    """
    Set up the drawing canvas to draw a banner numChars wide and numLines high.
    The coordinate system used assumes all characters are 20x20 and there
    are 10-point spaces between them.
    Precondition: The initial canvas is default size, then input by the first
    two user inputs, every input after that defines each letter's scale, probably between
    1 and 3 for the scale values to have the window visible on the screen.
    Postcondition: The turtle's starting position is at the bottom left
    corner of where the first character should be displayed, the letters are printed.
    """
    scale = int(input("scale, integer please"))
    
    # This setup function uses pixels for dimensions.
    # It creates the visible size of the canvas.
    canvas_height = 80 * numLines *scale
    canvas_width = 80 * numChars *scale
    turtle.setup( canvas_width *scale, canvas_height *scale)

    # This setup function establishes the coordinate system the
    # program perceives. It is set to match the planned number
    # of characters.
    height = 30 *scale
    width = 30 * numChars *scale
    margin = 5 # Add a bit to remove the problem with window decorations.
    turtle.setworldcoordinates(
        -margin+1 * scale, -margin+1 * scale, width + margin* scale, numLines*height + margin * scale)

    turtle.reset()
    turtle.up()
    turtle.setheading( 90 )
    turtle.forward( ( numLines - 1 ) * 30 )
    turtle.right( 90 )
    turtle.pensize( 1  *scale)
开发者ID:jonobrien,项目名称:School_Backups,代码行数:34,代码来源:spell_out.py

示例3: initBannerCanvas

def initBannerCanvas( numChars, numLines ):
    """
    Set up the drawing canvas to draw a banner numChars wide and numLines high.
    The coordinate system used assumes all characters are 20x20 and there
    are 10-point spaces between them.
    Postcondition: The turtle's starting position is at the bottom left
    corner of where the first character should be displayed.
    """
    # This setup function uses pixels for dimensions.
    # It creates the visible size of the canvas.
    canvas_height = 80 * numLines 
    canvas_width = 80 * numChars 
    turtle.setup( canvas_width, canvas_height )

    # This setup function establishes the coordinate system the
    # program perceives. It is set to match the planned number
    # of characters.
    height = 30 
    width = 30  * numChars
    margin = 5 # Add a bit to remove the problem with window decorations.
    turtle.setworldcoordinates(
        -margin+1, -margin+1, width + margin, numLines*height + margin )

    turtle.reset()
    turtle.up()
    turtle.setheading( 90 )
    turtle.forward( ( numLines - 1 ) * 30 )
    turtle.right( 90 )
    turtle.pensize( 2 * scale)
开发者ID:jonobrien,项目名称:School_Backups,代码行数:29,代码来源:spell_out.py

示例4: drawSootSprite

def drawSootSprite(N, R):
    # reset direction
    turtle.reset()
    # draw star
    drawStar(N, R)
    # draw body
    turtle.dot(0.8*2*R)
    # draw right eyeball
    turtle.fd(0.2*R)
    turtle.dot(0.3*R, 'white')
    # draw right pupil
    turtle.pu()
    turtle.bk(0.1*R)
    turtle.pd()
    turtle.dot(0.05*R)
    turtle.pu()
    # centre
    turtle.setpos(0, 0)
    # draw left eyeball
    turtle.bk(0.2*R)
    turtle.pd()
    turtle.dot(0.3*R, 'white')
    # draw left pupil
    turtle.pu()
    turtle.fd(0.1*R)
    turtle.pd()
    turtle.dot(0.05*R)

    turtle.hideturtle()
开发者ID:circulocity,项目名称:tp10,代码行数:29,代码来源:sootsprite.py

示例5: square

def square():
    for i in range(4):
        turtle.forward(100)
        turtle.left(90)
    raw_input('Press Enter')    
    clear()
    turtle.reset()
开发者ID:gustaveracosta,项目名称:Python,代码行数:7,代码来源:Program.py

示例6: draw_walk

def draw_walk(x, y, speed = 'slowest', scale = 20):
    ''' Animate a two-dimensional random walk.

    Args:
        x       x positions
        y       y positions
        speed   speed of the animation
        scale   scale of the drawing
    '''
    # Reset the turtle.
    turtle.reset()
    turtle.speed(speed)

    # Combine the x and y coordinates.
    walk = zip(x * scale, y * scale)
    start = next(walk)

    # Move the turtle to the starting point.
    turtle.penup()
    turtle.goto(*start)

    # Draw the random walk.
    turtle.pendown()
    for _x, _y in walk:
        turtle.goto(_x, _y)
开发者ID:AhmedHamedTN,项目名称:2015-python,代码行数:25,代码来源:random_walk.py

示例7: drawStar

def drawStar(N, R):
    turtle.reset()
    a = 360/N
    for i in range(N):
        turtle.fd(R)
        turtle.bk(R)
        turtle.left(a)
开发者ID:circulocity,项目名称:tp10,代码行数:7,代码来源:sootsprite.py

示例8: SetupClock

def SetupClock(radius):  
    # 建立表的外框  
    turtle.reset()  
    turtle.pensize(7)  
    for i in range(60):  
        Skip(radius)  
        if i % 5 == 0:  
            turtle.forward(20)  
            Skip(-radius - 20)  
             
            Skip(radius + 20)  
            if i == 0:  
                turtle.write(int(12), align="center", font=("Courier", 14, "bold"))  
            elif i == 30:  
                Skip(25)  
                turtle.write(int(i/5), align="center", font=("Courier", 14, "bold"))  
                Skip(-25)  
            elif (i == 25 or i == 35):  
                Skip(20)  
                turtle.write(int(i/5), align="center", font=("Courier", 14, "bold"))  
                Skip(-20)  
            else:  
                turtle.write(int(i/5), align="center", font=("Courier", 14, "bold"))  
            Skip(-radius - 20)  
        else:  
            turtle.dot(5)  
            Skip(-radius)  
        turtle.right(6)  
开发者ID:sfilata,项目名称:gitskills,代码行数:28,代码来源:clock.py

示例9: spiral

def spiral():
    n=5
    while n<100:
        turtle.circle(n, 180)
        n +=5
    raw_input('Press Enter')    
    clear()
    turtle.reset()
开发者ID:gustaveracosta,项目名称:Python,代码行数:8,代码来源:Program.py

示例10: tree

def tree(trunkLength,height):
    turtle.speed(1)
    turtle.reset()
    turtle.left(90)
    turtle.pu()
    turtle.backward(200)
    turtle.pd()
    grow(trunkLength,height)
开发者ID:HSaxton,项目名称:Python-things,代码行数:8,代码来源:TREE.PY

示例11: init_screen

def init_screen():
    # Delete the turtle's drawings from the screen, re-center the turtle and
    # set variables to the default values
    screen = turtle.Screen()
    screen.setup(width=500, height=500)
    screen.title('Yin Yang')
    turtle.reset()
    turtle.bgcolor('#E8E8F6')
    turtle.hideturtle()
开发者ID:mwoinoski,项目名称:crs1906,代码行数:9,代码来源:yinyang_multi_four_threads.py

示例12: trianglespiral

def trianglespiral():
    n=10
    while n<100:
        turtle.forward(n)
        turtle.left(120)
        n +=10
    raw_input('Press Enter')    
    clear()
    turtle.reset()
开发者ID:gustaveracosta,项目名称:Python,代码行数:9,代码来源:Program.py

示例13: circle

def circle():
    import math
    circunference = 2 * math.pi * 10
    n = int(circunference / 3) + 1
    length = circunference / n
    polygon(18, n, length)
    raw_input('Press Enter')
    clear()
    turtle.reset()
开发者ID:gustaveracosta,项目名称:Python,代码行数:9,代码来源:Program.py

示例14: new

def new():
    """Aids save and load functionality, and provides a 'blank-slate' method.

    Clears the current command list of all commands, refreshes the screen and
    returns the turtle to home.
    """
    global commandList
    commandList = []
    turtle.reset()
开发者ID:dan-may,项目名称:turtle,代码行数:9,代码来源:turtledraw.py

示例15: __setScreen

 def __setScreen(self):
     """set the screen/window depending on view static attributes."""
     turtle.resizemode('noresize')
     self.width = self.GRID_MARGINLEFT + 2 * self.gridWidth + self.GAP_BETWEEN_GRIDS + self.GRID_MARGINRIGHT
     self.height = self.GRID_MARGINTOP + self.gridWidth + self.GRID_MARGINBOTTOM
     turtle.setup(width=self.width + 10, height=self.height + 10)
     turtle.screensize(self.width, self.height)
     turtle.bgpic("Ressources/fire_ocean.gif")
     turtle.reset()
开发者ID:raphaelgodro,项目名称:BattleShip-Human-AI-Network,代码行数:9,代码来源:view_window.py


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