本文整理汇总了Python中turtle.Turtle.penup方法的典型用法代码示例。如果您正苦于以下问题:Python Turtle.penup方法的具体用法?Python Turtle.penup怎么用?Python Turtle.penup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类turtle.Turtle
的用法示例。
在下文中一共展示了Turtle.penup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import penup [as 别名]
class TurtleDisplay:
__start_point = None
__scale = (2, -2)
__offset = (-250, 250)
def __init__(self):
self.__turtle = Turtle()
def add_point(self, point):
x, y = self.translate(point)
if self.__start_point:
self.__turtle.goto(x, y)
else:
# self.__turtle.speed(0)
self.__turtle.tracer(100)
self.__start_point = point
self.__turtle.penup()
self.__turtle.goto(x, y)
self.__turtle.pendown()
def close_curve(self):
x, y = self.translate(self.__start_point)
self.__turtle.tracer(1)
self.__turtle.goto(x, y)
self.__start_point = None
def close(self):
print "Press enter to continue."
raw_input()
def translate(self, point):
x, y = point
xscale, yscale = self.__scale
xoff, yoff = self.__offset
return (xscale*x + xoff, yscale*y + yoff)
示例2: init_drawman
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import penup [as 别名]
def init_drawman():
global t, x_current, y_current
t=Turtle()
t.penup()
x_current = 0
y_current = 0
t.goto(x_current,y_current)
示例3: Lampe
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import penup [as 别名]
class Lampe():
lyser = False
turtle = None
def lag_skilpadde(self):
""" Lager en egen skilpadde for denne lamen."""
self.turtle = Turtle()
self.turtle.penup()
self.turtle.hideturtle()
# Gult lys når vi lyser.
self.turtle.shape('circle')
self.turtle.color('yellow')
self.turtle.shapesize(5)
def slaa_paa(self):
self.lyser = True
self.turtle.showturtle()
def slaa_av(self):
self.lyser = False
self.turtle.hideturtle()
示例4: setup
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import penup [as 别名]
def setup(color, distance):
t = Turtle()
t.pencolor(color)
t.penup()
t.forward(distance)
t.pendown()
return t
示例5: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import penup [as 别名]
def main():
screen.mode("logo")
t = Turtle(shape="triangle")
t.penup(); t.back(280); t.pendown()
t.pensize(3)
itree(t, 250, 0.63,
["black", "brown", "red", "orange", "violet", "lightblue"])
示例6: draw_table
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import penup [as 别名]
def draw_table(dimension: int, side: int, turtle: Turtle, x_coord: int, y_coord: int) -> None:
fill = False
for i in range(dimension ** 2):
if i % dimension == 0:
y_coord -= side
turtle.penup()
turtle.setpos(x_coord, y_coord)
turtle.pendown()
fill = fill != (dimension % 2 == 0)
if fill:
turtle.begin_fill()
for _ in range(4):
turtle.forward(side)
turtle.right(90)
if turtle.filling():
turtle.end_fill()
turtle.forward(side)
fill = not fill
done()
示例7: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import penup [as 别名]
def main():
p = Turtle()
p.color("green")
p.pensize(3)
#p.setundobuffer(None)
p.hideturtle() #Make the turtle invisible. It’s a good idea to do this while you’re in the middle of doing some complex drawing,
#because hiding the turtle speeds up the drawing observably.
#p.speed(10)
# p.getscreen().tracer(1,0)#Return the TurtleScreen object the turtle is drawing on.
p.speed(10)
#TurtleScreen methods can then be called for that object.
p.left(90)# Turn turtle left by angle units. direction 调整画笔
p.penup() #Pull the pen up – no drawing when moving.
p.goto(0, -80)#Move turtle to an absolute position. If the pen is down, draw line. Do not change the turtle’s orientation.
p.pendown()# Pull the pen down – drawing when moving. 这三条语句是一个组合相当于先把笔收起来再移动到指定位置,再把笔放下开始画
#否则turtle一移动就会自动的把线画出来
#t = tree([p], 200, 65, 0.6375)
t = tree([p], 200, 65, 0.6375)
p.penup() #Pull the pen up – no drawing when moving.
p.home()
p.goto(0, 80)
p.pendown()# P
p.right(90);
t1 = tree([p], 200, 65, 0.6375)
示例8: draw_line
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import penup [as 别名]
def draw_line(t: Turtle, start, end,*,
color="white", size=1):
t.pensize(size)
t.pencolor(color)
t.penup()
t.goto(*start)
t.pendown()
t.goto(*end)
示例9: init_drawman
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import penup [as 别名]
def init_drawman():
global t, x_current, y_current, _drawman_scale
t=Turtle()
t.penup()
x_current = 0
y_current = 0
t.goto(x_current, y_current)
drawman_scale(default_scale)
示例10: init_drawman
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import penup [as 别名]
def init_drawman():
global x_current, y_current, t, _drawman_scale
t=Turtle()
t.penup()
x_current=0
y_current=0
t.goto(x_current,y_current)
drawman_scale(default_scale) # функция задает масштаб по умолчанию
示例11: init_drawman
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import penup [as 别名]
def init_drawman():
""" Инициализация черепашки """
global t, x_current, y_current, _drawman_scale
t = Turtle()
t.penup()
x_current = 0
y_current = 0
t.goto(x_current, y_current)
drawman_scale(default_scale)
示例12: init_drawman
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import penup [as 别名]
def init_drawman():
global t, x_current, y_current, _drawman_scale
t=Turtle()
t.speed(100)
t.penup()
x_current = 0
y_current = 0
t.goto(x_current, y_current)
_drawman_scale = 10
示例13: init_drawman
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import penup [as 别名]
def init_drawman():
global t, x_current, y_current, _drawman_scale, dx, dy
t = Turtle()
t.penup()
x_current = 0
y_current = 0
dx = t.screen.window_width()/2
dy = t.screen.window_height()/2
t.goto(x_current, y_current)
drawman_scale(default_scale)
示例14: init_drawman
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import penup [as 别名]
def init_drawman():
global t, x_current, y_current, _drawman_scale, _step_grid, _count_point
t = Turtle()
t.penup()
x_current = 0
y_current = 0
t.goto(x_current, y_current)
_count_point = default_count_point
_step_grid = default_step_grid
drawman_scale(default_scale,default_step_grid)
示例15: maketree
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import penup [as 别名]
def maketree(x):
p = Turtle(shape="triangle", visible=False)
p.setundobuffer(None)
p.fillcolor("green")
p.shapesize(0.4)
p.speed(0)
p.left(90)
p.penup()
p.goto(x, -110)
p.pendown()
return tree([p], 140, 65, 0.6375)