Python turtle.penup() Examples
The following are 30
code examples of turtle.penup().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
turtle
, or try the search function
.
Example #1
Source File: clock.py From Tools with MIT License | 8 votes |
def start(): # 不显示绘制时钟的过程 turtle.tracer(False) turtle.mode('logo') createHand('second_hand', 150) createHand('minute_hand', 125) createHand('hour_hand', 85) # 秒, 分, 时 second_hand = turtle.Turtle() second_hand.shape('second_hand') minute_hand = turtle.Turtle() minute_hand.shape('minute_hand') hour_hand = turtle.Turtle() hour_hand.shape('hour_hand') for hand in [second_hand, minute_hand, hour_hand]: hand.shapesize(1, 1, 3) hand.speed(0) # 用于打印日期等文字 printer = turtle.Turtle() printer.hideturtle() printer.penup() createClock(160) # 开始显示轨迹 turtle.tracer(True) startTick(second_hand, minute_hand, hour_hand, printer) turtle.mainloop()
Example #2
Source File: spgl.py From SPGL with GNU General Public License v3.0 | 6 votes |
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)
Example #3
Source File: main.py From python-turtle-draw-svg with GNU General Public License v3.0 | 6 votes |
def Bezier_3(x1, y1, x2, y2, x3, y3, x4, y4): # 三阶贝塞尔函数 x1 = -Width / 2 + x1 y1 = Height / 2 - y1 x2 = -Width / 2 + x2 y2 = Height / 2 - y2 x3 = -Width / 2 + x3 y3 = Height / 2 - y3 x4 = -Width / 2 + x4 y4 = Height / 2 - y4 # 坐标变换 te.goto(x1, y1) te.pendown() for t in range(0, WriteStep + 1): x = Bezier(Bezier(Bezier(x1, x2, t / WriteStep), Bezier(x2, x3, t / WriteStep), t / WriteStep), Bezier(Bezier(x2, x3, t / WriteStep), Bezier(x3, x4, t / WriteStep), t / WriteStep), t / WriteStep) y = Bezier(Bezier(Bezier(y1, y2, t / WriteStep), Bezier(y2, y3, t / WriteStep), t / WriteStep), Bezier(Bezier(y2, y3, t / WriteStep), Bezier(y3, y4, t / WriteStep), t / WriteStep), t / WriteStep) te.goto(x, y) te.penup()
Example #4
Source File: main-colors-asymmetrical.py From python-examples with MIT License | 6 votes |
def item(lenght, level, color): if level <= 0: return for _ in range(5): # 5 turtle.color(colors[color]) turtle.forward(lenght) item(lenght/4, level-1, color+1) turtle.penup() # there is no need to draw again the same line (and it can use differnt color) turtle.backward(lenght) turtle.pendown() turtle.right(360/8) # 8 turtle.right(360/8 * 3) # 3 = 8 - 5
Example #5
Source File: homura.py From turtle-vectorgraph with MIT License | 6 votes |
def Bezier_3(x1, y1, x2, y2, x3, y3, x4, y4): # 三阶贝塞尔函数 x1 = -Width / 2 + x1 y1 = Height / 2 - y1 x2 = -Width / 2 + x2 y2 = Height / 2 - y2 x3 = -Width / 2 + x3 y3 = Height / 2 - y3 x4 = -Width / 2 + x4 y4 = Height / 2 - y4 # 坐标变换 te.goto(x1, y1) te.pendown() for t in range(0, WriteStep + 1): x = Bezier(Bezier(Bezier(x1, x2, t / WriteStep), Bezier(x2, x3, t / WriteStep), t / WriteStep), Bezier(Bezier(x2, x3, t / WriteStep), Bezier(x3, x4, t / WriteStep), t / WriteStep), t / WriteStep) y = Bezier(Bezier(Bezier(y1, y2, t / WriteStep), Bezier(y2, y3, t / WriteStep), t / WriteStep), Bezier(Bezier(y2, y3, t / WriteStep), Bezier(y3, y4, t / WriteStep), t / WriteStep), t / WriteStep) te.goto(x, y) te.penup()
Example #6
Source File: mandelbrot.py From advancedpython3 with GNU General Public License v3.0 | 6 votes |
def setup_screen(title, background='white', screen_size_x=640, screen_size_y=320, tracer_size=200): print('Set up Screen') turtle.title(title) turtle.setup(screen_size_x, screen_size_y) turtle.hideturtle() turtle.penup() turtle.backward(240) turtle.tracer(tracer_size) turtle.bgcolor(background) # Set the background colour of the screen
Example #7
Source File: homura.py From turtle-vectorgraph with MIT License | 5 votes |
def line(x1, y1, x2, y2): # 连接svg坐标下两点 te.penup() te.goto(-Width / 2 + x1, Height / 2 - y1) te.pendown() te.goto(-Width / 2 + x2, Height / 2 - y2) te.penup()
Example #8
Source File: spgl.py From SPGL with GNU General Public License v3.0 | 5 votes |
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)
Example #9
Source File: spgl.py From Projects with GNU General Public License v3.0 | 5 votes |
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
Example #10
Source File: spgl.py From Projects with GNU General Public License v3.0 | 5 votes |
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_name = font_name self.font_size = font_size self.font_type = font_type self.font = (font_name, font_size, font_type) self.align = align # Attributes self.text = text # Append to master label list Game.labels.append(self)
Example #11
Source File: spgl.py From Projects with GNU General Public License v3.0 | 5 votes |
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)
Example #12
Source File: main-colors.py From python-examples with MIT License | 5 votes |
def item(lenght, level, color): if level <= 0: return for _ in range(8): turtle.color(colors[color]) turtle.forward(lenght) item(lenght/4, level-1, color+1) turtle.penup() # there is no need to draw again the same line (and it can use differnt color) turtle.backward(lenght) turtle.pendown() turtle.right(360/8)
Example #13
Source File: homura.py From turtle-vectorgraph with MIT License | 5 votes |
def Bezier_2(x1, y1, x2, y2, x3, y3): # 二阶贝塞尔函数 te.goto(x1, y1) te.pendown() for t in range(0, WriteStep + 1): x = Bezier(Bezier(x1, x2, t / WriteStep), Bezier(x2, x3, t / WriteStep), t / WriteStep) y = Bezier(Bezier(y1, y2, t / WriteStep), Bezier(y2, y3, t / WriteStep), t / WriteStep) te.goto(x, y) te.penup()
Example #14
Source File: homura.py From turtle-vectorgraph with MIT License | 5 votes |
def Moveto(x, y): # 移动到svg坐标下(x,y) te.penup() te.goto(-Width / 2 + x, Height / 2 - y)
Example #15
Source File: spgl.py From SPGL with GNU General Public License v3.0 | 5 votes |
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)
Example #16
Source File: homura.py From turtle-vectorgraph with MIT License | 5 votes |
def lineto(dx, dy): # 连接当前点和相对坐标(dx,dy)的点 te.pendown() te.goto(te.xcor() + dx, te.ycor() - dy) te.penup()
Example #17
Source File: homura.py From turtle-vectorgraph with MIT License | 5 votes |
def Horizontal(x): # 做到svg坐标下横坐标为x的水平线 te.pendown() te.setx(x - Width / 2) te.penup()
Example #18
Source File: homura.py From turtle-vectorgraph with MIT License | 5 votes |
def horizontal(dx): # 做到相对横坐标为dx的水平线 te.seth(0) te.pendown() te.fd(dx) te.penup()
Example #19
Source File: homura.py From turtle-vectorgraph with MIT License | 5 votes |
def vertical(dy): # 做到相对纵坐标为dy的垂直线 te.seth(-90) te.pendown() te.fd(dy) te.penup() te.seth(0)
Example #20
Source File: homura.py From turtle-vectorgraph with MIT License | 5 votes |
def polyline(x1, y1, x2, y2, x3, y3): # 做svg坐标下的折线 te.penup() te.goto(-Width / 2 + x1, Height / 2 - y1) te.pendown() te.goto(-Width / 2 + x2, Height / 2 - y2) te.goto(-Width / 2 + x3, Height / 2 - y3) te.penup()
Example #21
Source File: homura.py From turtle-vectorgraph with MIT License | 5 votes |
def Curveto(x1, y1, x2, y2, x, y): # 三阶贝塞尔曲线到(x,y) te.penup() X_now = te.xcor() + Width / 2 Y_now = Height / 2 - te.ycor() Bezier_3(X_now, Y_now, x1, y1, x2, y2, x, y) global Xh global Yh Xh = x - x2 Yh = y - y2
Example #22
Source File: homura.py From turtle-vectorgraph with MIT License | 5 votes |
def Smooth(x2, y2, x, y): # 平滑三阶贝塞尔曲线到(x,y) global Xh global Yh te.penup() X_now = te.xcor() + Width / 2 Y_now = Height / 2 - te.ycor() Bezier_3(X_now, Y_now, X_now + Xh, Y_now + Yh, x2, y2, x, y) Xh = x - x2 Yh = y - y2
Example #23
Source File: homura.py From turtle-vectorgraph with MIT License | 5 votes |
def smooth_r(x2, y2, x, y): # 平滑三阶贝塞尔曲线到相对坐标(x,y) global Xh global Yh te.penup() X_now = te.xcor() + Width / 2 Y_now = Height / 2 - te.ycor() Bezier_3(X_now, Y_now, X_now + Xh, Y_now + Yh, X_now + x2, Y_now + y2, X_now + x, Y_now + y) Xh = x - x2 Yh = y - y2
Example #24
Source File: snowflake.py From advancedpython3 with GNU General Public License v3.0 | 5 votes |
def setup_screen(title, background = 'white'): print('Set up Screen') turtle.title(title) turtle.setup(640, 600) turtle.hideturtle() turtle.penup() turtle.tracer(200) turtle.bgcolor(background) # Set the background colour of the screen
Example #25
Source File: main.py From python-turtle-draw-svg with GNU General Public License v3.0 | 5 votes |
def Bezier_2(x1, y1, x2, y2, x3, y3): # 二阶贝塞尔函数 te.goto(x1, y1) te.pendown() for t in range(0, WriteStep + 1): x = Bezier(Bezier(x1, x2, t / WriteStep), Bezier(x2, x3, t / WriteStep), t / WriteStep) y = Bezier(Bezier(y1, y2, t / WriteStep), Bezier(y2, y3, t / WriteStep), t / WriteStep) te.goto(x, y) te.penup()
Example #26
Source File: main.py From python-turtle-draw-svg with GNU General Public License v3.0 | 5 votes |
def Moveto(x, y): # 移动到svg坐标下(x,y) te.penup() te.goto(-Width / 2 + x, Height / 2 - y) te.pendown()
Example #27
Source File: main.py From python-turtle-draw-svg with GNU General Public License v3.0 | 5 votes |
def Moveto_r(dx, dy): te.penup() te.goto(te.xcor() + dx, te.ycor() - dy) te.pendown()
Example #28
Source File: main.py From python-turtle-draw-svg with GNU General Public License v3.0 | 5 votes |
def line(x1, y1, x2, y2): # 连接svg坐标下两点 te.penup() te.goto(-Width / 2 + x1, Height / 2 - y1) te.pendown() te.goto(-Width / 2 + x2, Height / 2 - y2) te.penup()
Example #29
Source File: main.py From python-turtle-draw-svg with GNU General Public License v3.0 | 5 votes |
def Lineto(x, y): # 连接当前点和svg坐标下(x,y) te.pendown() te.goto(-Width / 2 + x, Height / 2 - y) te.penup()
Example #30
Source File: main.py From python-turtle-draw-svg with GNU General Public License v3.0 | 5 votes |
def Curveto(x1, y1, x2, y2, x, y): # 三阶贝塞尔曲线到(x,y) te.penup() X_now = te.xcor() + Width / 2 Y_now = Height / 2 - te.ycor() Bezier_3(X_now, Y_now, x1, y1, x2, y2, x, y) global Xh global Yh Xh = x - x2 Yh = y - y2