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

Python turtle.reset函数代码示例

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

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



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


示例16: rectangle

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


示例17: triangle

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


示例18: main

def main():
    """
    :pre:(relative) pos (0,0), heading (east), up
    :post:(relative) pos (X,0), heading (east), up
    :return: none 
    """
    
    numberOfTree=int(raw_input("How many trees in your forest ?"))
    treeHome=["Mapel","Pine","bodhiTree"]
    dummy_house=raw_input("Is there a house in the forest (y/n)?")
    highestHeight=50

    treeHomeRandom=[treeHome[r.randint(0,2)] for n in range(numberOfTree) ]
    if dummy_house in ['Y','y']:
        if numberOfTree>2:
           treeHomeRandom.insert(r.randint(1,numberOfTree-2),"House")
        elif numberOfTree<=2:
             treeHomeRandom.insert(1,"House")  
    if numberOfTree <= 11:
        if dummy_house in ['Y','y']:
          init(-(numberOfTree+1)*100/2,-100)
        else: 
          init(-(numberOfTree)*100/2,-100)
    else:
         init(-600,-100)

    #print(treeHomeRandom)
    totalWood=0
    for myTree in treeHomeRandom:
       (length,totalWood)=treeAndHouse(myTree,totalWood)
       if length>highestHeight:
           highestHeight=length
       t.up()
       t.forward(100)
       t.down()
    t.up()
    t.back(100)
    star2(highestHeight+10)
    
    raw_input("Night is done Press Enter for day")
    
    t.reset()
    print("We have " + str(totalWood) +" units of lumber for building." )
    print ("We will build a house with walls " + str((totalWood)/(2+math.sqrt(2)))+ " tall.")
    init(0,-300)
    house((totalWood)/(2+math.sqrt(2)))
    t.left(90)
    t.forward(3*abs((totalWood)/(2+math.sqrt(2)))/2+30)
    t.right(90)
    maple_shape(30)
    t.right(90)
    t.up()
    t.back(3*abs((totalWood)/(2+math.sqrt(2)))/2+30)
    t.right(90)
    raw_input("Day is done, house is build, Press enter to quit")
开发者ID:deepaksharma36,项目名称:Python-Assignements,代码行数:55,代码来源:forest.py


示例19: show_result

def show_result(convex,usetime,color,algorithm):
    drawpoint(pointset,'black')
    drawpoint(convex,color)
    drawline(convex,color)
    turtle.up()
    #turtle.pensize(400)
    turtle.goto(-60,min_y-30)
    turtle.down()
    turtle.write('%s,use time:%s'%(algorithm,str(usetime)))
    time.sleep(10)
    turtle.reset()
开发者ID:yhldhit,项目名称:basic-algorithm,代码行数:11,代码来源:convex_hull.py


示例20: __init__

 def __init__(self,actions,drawColour="black"):
     self.actions = actions
     self.stack = []
     t.setup()
     # Try to make the animation of drawing reasonably fast.
     t.tracer(100,0) # Only draw every 50th update, set delay to zero.
     t.title ("Jose Javier's L System demo")
     t.reset()
     t.degrees()
     t.color(drawColour)
     t.hideturtle() # don't draw the turtle; increase drawing speed.
开发者ID:JJGO,项目名称:Parallel-LSystem,代码行数:11,代码来源:LSystem.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python turtle.right函数代码示例发布时间:2022-05-27
下一篇:
Python turtle.register_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