當前位置: 首頁>>代碼示例>>Python>>正文


Python turtle.up方法代碼示例

本文整理匯總了Python中turtle.up方法的典型用法代碼示例。如果您正苦於以下問題:Python turtle.up方法的具體用法?Python turtle.up怎麽用?Python turtle.up使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在turtle的用法示例。


在下文中一共展示了turtle.up方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: square

# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import up [as 別名]
def square(x, y, size, name):
    """Draw square at `(x, y)` with side length `size` and fill color `name`.

    The square is oriented so the bottom left corner is at (x, y).

    """
    import turtle
    turtle.up()
    turtle.goto(x, y)
    turtle.down()
    turtle.color(name)
    turtle.begin_fill()

    for count in range(4):
        turtle.forward(size)
        turtle.left(90)

    turtle.end_fill() 
開發者ID:PacktPublishing,項目名稱:Learning-Python-by-building-games,代碼行數:20,代碼來源:base.py

示例2: line

# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import up [as 別名]
def line(a, b, x, y):
    "Draw line from `(a, b)` to `(x, y)`."
    import turtle
    turtle.up()
    turtle.goto(a, b)
    turtle.down()
    turtle.goto(x, y) 
開發者ID:PacktPublishing,項目名稱:Learning-Python-by-building-games,代碼行數:9,代碼來源:base.py

示例3: permissibilities

# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import up [as 別名]
def permissibilities(self, cell):
        '''
        Check if the directions of a given cell are permissible.
        Return:
        (up, right, down, left)
        '''
        cell_value = self.maze[cell[0], cell[1]]
        return (cell_value & 1 == 0, cell_value & 2 == 0, cell_value & 4 == 0, cell_value & 8 == 0) 
開發者ID:leimao,項目名稱:Particle_Filter,代碼行數:10,代碼來源:maze.py

示例4: distance_to_walls

# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import up [as 別名]
def distance_to_walls(self, coordinates):
        '''
        Measure the distance of coordinates to nearest walls at four directions.
        Return:
        (up, right, down, left)
        '''

        x, y = coordinates

        i = int(y // self.grid_height)
        j = int(x // self.grid_width)
        d1 = y - y // self.grid_height * self.grid_height
        while self.permissibilities(cell = (i,j))[0]:
            i -= 1
            d1 += self.grid_height

        i = int(y // self.grid_height)
        j = int(x // self.grid_width)
        d2 = self.grid_width - (x - x // self.grid_width * self.grid_width)
        while self.permissibilities(cell = (i,j))[1]:
            j += 1
            d2 += self.grid_width

        i = int(y // self.grid_height)
        j = int(x // self.grid_width)
        d3 = self.grid_height - (y - y // self.grid_height * self.grid_height)
        while self.permissibilities(cell = (i,j))[2]:
            i += 1
            d3 += self.grid_height

        i = int(y // self.grid_height)
        j = int(x // self.grid_width)
        d4 = x - x // self.grid_width * self.grid_width
        while self.permissibilities(cell = (i,j))[3]:
            j -= 1
            d4 += self.grid_width

        return [d1, d2, d3, d4] 
開發者ID:leimao,項目名稱:Particle_Filter,代碼行數:40,代碼來源:maze.py

示例5: hexagone

# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import up [as 別名]
def hexagone(point, longueur,c):
   l = longueur

   x, y = point

   turtle.up()
   turtle.goto(point)
   turtle.color(c[0]) #black
   turtle.down()
   turtle.begin_fill() 
   turtle.goto(l * cos(4 / 3 * pi )+x, l * sin(4 / 3 * pi)+y)
   turtle.goto(l * cos(5 / 3 * pi)+x, l * sin(5 / 3 * pi)+y)
   turtle.goto(l * cos(0)+x, l * sin(0)+y) 
   turtle.goto(point) 
   turtle.end_fill()

   turtle.color(c[1])  #blue
   turtle.begin_fill()
   turtle.goto(l * cos(0)+x, l * sin(0)+y) 
   turtle.goto(l * cos(pi / 3)+x, l * sin(pi / 3)+y)
   turtle.goto(l * cos(pi * 2 / 3)+x, l * sin(pi * 2 / 3)+y)
   turtle.goto(point)  
   turtle.end_fill()

   turtle.color(c[2]) #red
   turtle.begin_fill()
   turtle.goto(l * cos(pi * 2 / 3)+x, l * sin(pi * 2 / 3)+y)
   turtle.goto(-l+x, 0+y)
   turtle.goto(l * cos(4 / 3 * pi)+x, l * sin(4 / 3 * pi)+y)
   turtle.goto(point)
   turtle.end_fill()
   turtle.up()

   return True 
開發者ID:furas,項目名稱:python-examples,代碼行數:36,代碼來源:main.py

示例6: drawCircleTurle

# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import up [as 別名]
def drawCircleTurle(x,y,r):
    # move to the start of circle
    turtle.up()
    turtle.setpos(x+r,y)
    turtle.down()


     # draw the circle
    for i in range(0,365,5):
        a=math.radians(i)
        turtle.setpos(x+r*math.cos(a),y+r*math.sin(a)) 
開發者ID:DeqianBai,項目名稱:Python-Project,代碼行數:13,代碼來源:drawcircle.py

示例7: show_maze

# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import up [as 別名]
def show_maze(self):

        turtle.setworldcoordinates(0, 0, self.width * 1.005, self.height * 1.005)

        wally = turtle.Turtle()
        wally.speed(0)
        wally.width(1.5)
        wally.hideturtle()
        turtle.tracer(0, 0)

        for i in range(self.num_rows):
            for j in range(self.num_cols):
                permissibilities = self.permissibilities(cell = (i,j))
                turtle.up()
                wally.setposition((j * self.grid_width, i * self.grid_height))
                # Set turtle heading orientation
                # 0 - east, 90 - north, 180 - west, 270 - south
                wally.setheading(0)
                if not permissibilities[0]:
                    wally.down()
                else:
                    wally.up()
                wally.forward(self.grid_width)
                wally.setheading(90)
                wally.up()
                if not permissibilities[1]:
                    wally.down()
                else:
                    wally.up()
                wally.forward(self.grid_height)
                wally.setheading(180)
                wally.up()
                if not permissibilities[2]:
                    wally.down()
                else:
                    wally.up()
                wally.forward(self.grid_width)
                wally.setheading(270)
                wally.up()
                if not permissibilities[3]:
                    wally.down()
                else:
                    wally.up()
                wally.forward(self.grid_height)
                wally.up()

        turtle.update() 
開發者ID:leimao,項目名稱:Particle_Filter,代碼行數:49,代碼來源:maze.py


注:本文中的turtle.up方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。