Python turtle 模块,penup() 实例源码

我们从Python开源项目中,提取了以下18个代码示例,用于说明如何使用turtle.penup()

项目:SPGL    作者:wynand1004    | 项目源码 | 文件源码
def __init__(self,
                text,
                color,
                x = 0,
                y = 0,
                font_name = "Arial",
                font_size = 12,
                font_type = "normal",
                align = "left"):

        turtle.Turtle.__init__(self)
        self.hideturtle()
        self.penup()
        self.goto(x, y)
        self.color(color)
        self.font = (font_name, font_size, font_type)
        self.align = align

        # Attributes
        self.text = text


        # Append to master label list
        Game.labels.append(self)
项目:SPGL    作者:wynand1004    | 项目源码 | 文件源码
def __init__(self,
                text,
                color,
                x = 0,
                y = 0,
                font_name = "Arial",
                font_size = 12,
                font_type = "normal",
                align = "left"):

        turtle.Turtle.__init__(self)
        self.hideturtle()
        self.penup()
        self.goto(x, y)
        self.color(color)
        self.font = (font_name, font_size, font_type)
        self.align = align

        # Attributes
        self.text = text


        # Append to master label list
        Game.labels.append(self)
项目:MyKnowledge    作者:guofei9987    | 项目源码 | 文件源码
def Init():
    global secHand, minHand, hurHand, printer
    turtle.mode("logo")  # ??Turtle???
    # ??????Turtle????
    mkHand("secHand", 125)
    mkHand("minHand", 130)
    mkHand("hurHand", 90)
    secHand = turtle.Turtle()
    secHand.shape("secHand")
    minHand = turtle.Turtle()
    minHand.shape("minHand")
    hurHand = turtle.Turtle()
    hurHand.shape("hurHand")
    for hand in secHand, minHand, hurHand:
        hand.shapesize(1, 1, 3)
        hand.speed(0)
    # ??????Turtle
    printer = turtle.Turtle()
    printer.hideturtle()
    printer.penup()
项目:SPGL    作者:wynand1004    | 项目源码 | 文件源码
def __init__(
                self,
                screen_width = 800,
                screen_height = 600,
                background_color = "black",
                title = "Simple Game Library by /u/wynand1004 AKA @TokyoEdTech",
                splash_time = 3):

        # Setup using Turtle module methods
        turtle.setup(width=screen_width, height=screen_height)
        turtle.bgcolor(background_color)
        turtle.title(title)
        turtle.tracer(0) # Stop automatic screen refresh
        turtle.listen() # Listen for keyboard input
        turtle.hideturtle() # Hides default turtle
        turtle.penup() # Puts pen up for defaut turtle
        turtle.setundobuffer(0) # Do not keep turtle history in memory
        turtle.onscreenclick(self.click)

        # Game Attributes
        self.FPS = 30.0 # Lower this on slower computers or with large number of sprites
        self.SCREEN_WIDTH = screen_width
        self.SCREEN_HEIGHT = screen_height
        self.DATAFILE = "game.dat"
        self.SPLASHFILE = "splash.gif" # Must be in the same folder as game file

        self.title = title
        self.gravity = 0
        self.state = "showsplash"
        self.splash_time = splash_time

        self.time = time.time()

        # Clear the terminal and print the game title
        self.clear_terminal_screen()
        print (self.title)

        # Show splash
        self.show_splash(self.splash_time)

    # Pop ups
项目:SPGL    作者:wynand1004    | 项目源码 | 文件源码
def __init__(self,
                shape,
                color,
                x = 0,
                y = 0):

        turtle.Turtle.__init__(self)
        # self.hideturtle()
        self.penup()
        # Register shape if it is a .gif file
        if shape.endswith(".gif"):
            try:
                turtle.register_shape(shape)
            except:
                Game.logs.append("Warning: {} file missing from disk.".format(shape))

                # Set placeholder shape
                shape = "square"

        self.shape(shape)
        self.color(color)
        self.goto(x, y)

        #Set click binding
        self.onclick(self.click)

        # Append to master button list
        Game.buttons.append(self)
项目:SPGL    作者:wynand1004    | 项目源码 | 文件源码
def __init__(
                self,
                screen_width = 800,
                screen_height = 600,
                background_color = "black",
                title = "Simple Game Library by /u/wynand1004 AKA @TokyoEdTech",
                splash_time = 3):

        # Setup using Turtle module methods
        turtle.setup(width=screen_width, height=screen_height)
        turtle.bgcolor(background_color)
        turtle.title(title)
        turtle.tracer(0) # Stop automatic screen refresh
        turtle.listen() # Listen for keyboard input
        turtle.hideturtle() # Hides default turtle
        turtle.penup() # Puts pen up for defaut turtle
        turtle.setundobuffer(0) # Do not keep turtle history in memory
        turtle.onscreenclick(self.click)

        # Game Attributes
        self.FPS = 30.0 # Lower this on slower computers or with large number of sprites
        self.SCREEN_WIDTH = screen_width
        self.SCREEN_HEIGHT = screen_height
        self.DATAFILE = "game.dat"
        self.SPLASHFILE = "splash.gif" # Must be in the same folder as game file

        self.title = title
        self.gravity = 0
        self.state = "showsplash"
        self.splash_time = splash_time

        self.time = time.time()

        # Clear the terminal and print the game title
        self.clear_terminal_screen()
        print (self.title)

        # Show splash
        self.show_splash(self.splash_time)

    # Pop ups
项目:SPGL    作者:wynand1004    | 项目源码 | 文件源码
def __init__(self,
                shape,
                color,
                x = 0,
                y = 0):

        turtle.Turtle.__init__(self)
        # self.hideturtle()
        self.penup()
        # Register shape if it is a .gif file
        if shape.endswith(".gif"):
            try:
                turtle.register_shape(shape)
            except:
                Game.logs.append("Warning: {} file missing from disk.".format(shape))

                # Set placeholder shape
                shape = "square"

        self.shape(shape)
        self.color(color)
        self.goto(x, y)

        #Set click binding
        self.onclick(self.click)

        # Append to master button list
        Game.buttons.append(self)
项目:L-Systems-Compiler-And-Renderer    作者:Mizzlr    | 项目源码 | 文件源码
def draw(self):
        "draws the lsystem on the screen"
        stack = []
        tt.penup()
        tt.setpos(0, -200)
        tt.seth(90)
        tt.pendown()

        print "Drawing the lsystem ..."
        for i, codebit in enumerate(self.generation[-1]):

            if codebit in ['F', 'A', 'B']:
                tt.forward(self.length)
                print '[ FRWD ] ', codebit
            elif codebit == '+':
                tt.right(self.angle)
                print '[ RGHT ] ', codebit
            elif codebit == '-':
                tt.left(self.angle)
                print '[ LEFT ] ', codebit
            elif codebit == '[':
                stack.append((tt.pos(), tt.heading()))
                print '[ PUSH ] ', (tt.pos(), tt.heading())
            elif codebit == ']':
                position,heading = stack.pop()
                print '[ POP  ] ', (position, heading)
                tt.penup()
                tt.goto(position)
                tt.seth(heading)
                tt.pendown()
            else:
                print '[ NOP  ] ', codebit

            if self.save_every_frame:
                self.save(frame=i)

        print "Done drawing"
        print "Saving file as %s.jpg" % self.name,
        self.save()
        print "Done"
项目:jvcprojectortools    作者:arvehj    | 项目源码 | 文件源码
def draw_line(self, pos, horizontal=False, label=None,
                  color='gray90', label_color='gray35', **_):
        """Draw one horizontal or vertical line with optional color and label"""
        if pos is None:
            return
        if pos < self.zoom_area[0 + horizontal] or pos > self.zoom_area[2 + horizontal]:
            return
        turtle.penup()
        xscale = turtle.getscreen().xscale
        yscale = turtle.getscreen().yscale
        if label:
            font_family, font_size = self.font
            turtle.color(label_color)
            turtle.setposition(*self.label_pos(pos=pos, label=label, horizontal=horizontal))
            turtle.write(label, align='right' if horizontal else'center',
                         font=(font_family, font_size))
            turtle.setposition(-4 / xscale if horizontal else pos,
                               pos if horizontal else -4 / yscale)
            turtle.pendown()
        turtle.setposition(1 / xscale if horizontal else pos,
                           pos if horizontal else 1 / yscale)
        turtle.color(color)
        turtle.pendown()
        turtle.setposition(self.plot_area[2] if horizontal else pos,
                           pos if horizontal else self.plot_area[3])
        turtle.penup()
项目:jvcprojectortools    作者:arvehj    | 项目源码 | 文件源码
def plot_table(self, *gamma, colors=['red', 'green', 'blue'], draw_speed=16, scale_x=1):
        """Plot gamma table"""
        if len(gamma) == 1 and len(gamma[0]) == 3:
            gamma = gamma[0]
        if all(x == gamma[0] for x in gamma):
            gamma = gamma[:1]

        turtle.penup()
        turtle.tracer(0, 16)
        turtle.speed(0)
        turtle.color('black')
        for color, points_y in enumerate(gamma):
            if len(gamma) == len(colors):
                turtle.color(colors[color])
            elif len(colors) == 1:
                turtle.color(colors[0])
            for x, y in enumerate(points_y):
                trace = x and x % draw_speed == 0
                if trace:
                    turtle.tracer(1)
                turtle.setposition(x * scale_x, y)
                if trace:
                    turtle.tracer(0)
                if x == 0:
                    turtle.showturtle()
                    turtle.pendown()

            turtle.penup()
            turtle.hideturtle()
            turtle.update()
项目:MyKnowledge    作者:guofei9987    | 项目源码 | 文件源码
def Skip(step):
    turtle.penup()
    turtle.forward(step)
    turtle.pendown()
项目:nautical-combat    作者:horstjens    | 项目源码 | 文件源码
def zweig(laenge = 10, winkel=30, divisor=2):
    if laenge < 2:
        return
    turtle.forward(laenge)
    turtle.left(winkel)
    zweig(laenge//divisor, winkel, divisor)
    turtle.right(winkel*2)
    zweig(laenge//divisor, winkel, divisor)
    turtle.left(winkel)
    turtle.penup()
    turtle.forward(-laenge)
    turtle.pendown()
项目:IPC_2017-1    作者:jucimarjr    | 项目源码 | 文件源码
def draw_star(x, y, side):
    star_angle = 360.0/6
    left_angle = star_angle * 2
    tu.penup()
    tu.goto(x, y)
    tu.pendown()
    for i in range(6):
        tu.forward(side)
        tu.right(star_angle)
        tu.forward(side)
        tu.left(left_angle)
项目:Scheme    作者:StephenK1998    | 项目源码 | 文件源码
def tscheme_penup():
    """Raise the pen, so that the turtle does not draw."""
    _tscheme_prep()
    turtle.penup()
    return okay
项目:Charon    作者:forrestchang    | 项目源码 | 文件源码
def tscheme_penup():
    """Raise the pen, so that the turtle does not draw."""
    _tscheme_prep()
    turtle.penup()
    return okay
项目:SchemeInterpreter    作者:GrantHiggins16    | 项目源码 | 文件源码
def tscheme_penup():
    """Raise the pen, so that the turtle does not draw."""
    _tscheme_prep()
    turtle.penup()
    return okay
项目:SPGL    作者:wynand1004    | 项目源码 | 文件源码
def __init__(self,
                shape,
                color,
                x = 0,
                y = 0,
                width = 20,
                height = 20):

        turtle.Turtle.__init__(self)
        self.speed(0) # Animation Speed
        # Register shape if it is a .gif file
        if shape.endswith(".gif"):
            try:
                turtle.register_shape(shape)
            except:
                Game.logs.append("Warning: {} file missing from disk.".format(shape))

                # Set placeholder shape
                shape = "square"
                width = 20 # This is the default for turtle module primitives
                height = 20 # This is the default for turtle module primitives

        self.shape(shape)
        self.color(color)
        self.penup()
        self.goto(x, y)

        # Attributes
        self.width = width
        self.height = width

        self.speed = 0.0 # Speed of motion
        self.dx = 0.0
        self.dy = 0.0
        self.acceleration = 0.0
        self.friction = 0.0

        self.state = "active"
        self.solid = True

        #Set click binding
        self.onclick(self.click)

        # Append to master sprite list
        Game.sprites.append(self)
项目:dwinelle-tools    作者:dkess    | 项目源码 | 文件源码
def draw_floor(floornum: int):
    global current_floor
    current_floor = floornum

    node_coords = utils.get_node_coords(utils.Direction.left) 

    if floornum == len(full_floors):
        rooms = []
        # All edges with rooms
        print('Showing everything')
        edges = chain.from_iterable(chain(((True, e) for e in edges[0]), ((False, e) for e in edges[1])) for _, edges in full_floors)
        # Edges with elevation changes
        #edges = set(chain.from_iterable((edge(v, n) for n in b.values() if set(['u', 'd']) & set(utils.get_graph().edgedata[edge(v, n)]['rooms'])) for v, b in enumerate(utils.get_graph().branches)))
        # All edges
        #...
    elif floornum >= 0 and floornum < len(full_floors):
        rooms, edges = full_floors[floornum]
        print(edges)
        edges = chain(((True, e) for e in edges[0]), ((False, e) for e in edges[1]))
        print(rooms)
    else:
        return

    turtle.showturtle()
    turtle.speed(0)
    turtle.clear()

    written_nodes = set()

    for edge_dir, (a, b) in edges:
        turtle.penup()
        x, y, _ = node_coords[a]
        turtle.goto(x / SHRINK + X_OFFSET, y / SHRINK + Y_OFFSET)
        if a not in written_nodes:
            turtle.write(a)
            written_nodes.add(a)

        turtle.pendown()

        if edge_dir:
            if edge_lengths[edge(a, b)] <= 0:
                turtle.pencolor('red')
            else:
                turtle.pencolor('black')
        else:
            if edge_lengths[edge(a, b)] <= 0:
                turtle.pencolor('blue')
            else:
                turtle.pencolor('green')

        x, y, _ = node_coords[b]
        turtle.goto(x / SHRINK + X_OFFSET, y / SHRINK + Y_OFFSET)
        turtle.pencolor('black')
        if b not in written_nodes:
            turtle.write(b)
            written_nodes.add(b)

    turtle.hideturtle()
    turtle.done()