本文整理汇总了Python中turtle.penup函数的典型用法代码示例。如果您正苦于以下问题:Python penup函数的具体用法?Python penup怎么用?Python penup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了penup函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: alpha_beta_helper
def alpha_beta_helper():
global state, root, alpha_time
initialize()
print("PLEASE WAIT!!!")
root = TreeNode(-1000)
time1 = time.time()
alpha_beta(root, 1, state)
init_screen()
drawLine()
drawGrid()
drawColumns()
drawRows()
caliberate()
col = root.ans
row = -1
turtle.onscreenclick(goto)
for i in range(4):
if state[i][col] == 0:
row = i
break
state[row][col] = 1
drawDot(row, col, 1)
var = (int)(input("Enter 1 to continue playing or 0 to stop."))
time2 = time.time()
alpha_time = time2-time1
if(var == 1):
turtle.clear()
turtle.goto(0, 0)
turtle.penup()
turtle.right(270)
alpha_beta_helper()
else:
write_analysis(3)
示例2: draw_circle
def draw_circle(x,y):
turtle.penup()
turtle.goto(x,y)
turtle.pendown()
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
示例3: draw
def draw(cmds, size=2): #output tree
stack = []
for cmd in cmds:
if cmd=='F':
turtle.forward(size)
elif cmd=='-':
t = random.randrange(0,7,1)
p = ["Red","Green","Blue","Grey","Yellow","Pink","Brown"]
turtle.color(p[t])
turtle.left(15) #slope left
elif cmd=='+':
turtle.right(15) #slope right
t = random.randrange(0,7,1) #рандомная пер. для цвета
p = ["Red","Green","Blue","Grey","Yellow","Pink","Brown"] #ряд цветов
turtle.color(p[t]) #выбор цвета из ряда
elif cmd=='X':
pass
elif cmd=='[':
stack.append((turtle.position(), turtle.heading()))
elif cmd==']':
position, heading = stack.pop()
turtle.penup()
turtle.setposition(position)
turtle.setheading(heading)
turtle.pendown()
turtle.update()
示例4: draw_star
def draw_star(size, color):
turtle.pendown()
turtle.begin_fill()
turtle.color(1,1,1)
turtle.forward(2.5)
turtle.left(size)
turtle.forward(2.5)
turtle.right(144)
turtle.forward(2.5)
turtle.left(size)
turtle.forward(2.5)
turtle.right(144)
turtle.forward(2.5)
turtle.left(size)
turtle.forward(2.5)
turtle.right(144)
turtle.forward(2.5)
turtle.left(size)
turtle.forward(2.5)
turtle.right(144)
turtle.forward(2.5)
turtle.left(size)
turtle.forward(2.5)
turtle.right(144)
turtle.end_fill()
turtle.penup()
示例5: entrance
def entrance(pointOne):
turtle.goto(pointOne[0], pointOne[1] + 36)
turtle.setheading(270)
turtle.pendown()
turtle.forward(15)
turtle.penup()
drawArrows()
示例6: circunferencia
def circunferencia(simbolos,identificador,linea):
p1= obtener_punto(2,identificador,simbolos)
radio = obtener_radio(identificador,simbolos)
x1 = obtener_x(p1,simbolos)
y1 = obtener_y(p1,simbolos)
escalar = obtener_escalar(identificador, simbolos,linea)
relleno = obtener_color(obtener_relleno(identificador,simbolos,linea))
borde = obtener_color(obtener_borde(identificador,simbolos,linea))
turtle.color(borde)
if escalar == 0:
escalar=1
tx = obtener_tx(identificador, simbolos,linea)
ty = obtener_ty(identificador, simbolos,linea)
turtle.pensize(8)
turtle.penup()
#Trasladar circunferencia
x1 = x1 + tx
y1 = y1 + ty
#turtle.setposition(x1, y1-(radio*44))
#turtle.pendown()
#turtle.circle(radio*44)
#Escalar circunferencia
turtle.penup()
#turtle.setposition(x1, y1-(radio*44*escalar))
turtle.setposition(x1*44, (y1*44)-(radio*44*escalar))
turtle.pendown()
turtle.fillcolor(relleno)
turtle.begin_fill()
turtle.circle(radio*44*escalar)
turtle.end_fill()
示例7: at
def at(x, y):
turtle.penup()
turtle.home()
turtle.forward(x)
turtle.left(90)
turtle.forward(y)
turtle.pendown()
示例8: draw_grid
def draw_grid(ll,ur):
size = ur - ll
for gridsize in [1, 2, 5, 10, 20, 50, 100 ,200, 500]:
lines = (ur-ll)/gridsize
# print('gridsize', gridsize, '->', int(lines)+1, 'lines')
if lines <= 11: break
turtle.color('gray')
turtle.width(1)
x = ll
while x <= ur:
if int(x/gridsize)*gridsize == x:
turtle.penup()
turtle.goto(x, ll-.25*gridsize)
turtle.write(str(x),align="center",font=("Arial",12,"normal"))
turtle.goto(x,ll)
turtle.pendown()
turtle.goto(x,ur)
# print(x,ll,'to',x,ur)
x += 1
y = ll
while y <= ur:
# horizontal grid lines:
if int(y/gridsize)*gridsize == y:
turtle.penup()
turtle.goto(ll-.1*gridsize, y - .06*gridsize)
turtle.write(str(y),align="right",font=("Arial",12,"normal"))
turtle.goto(ll,y)
turtle.pendown()
turtle.goto(ur,y)
# print(ll,y,'to',ur,y)
y += 1
示例9: printwin
def printwin(turtle):
turtle.stamp()
turtle.hideturtle()
turtle.penup()
turtle.goto(0,0)
turtle.color("green")
turtle.write("You Win!",font=("Arial",30), align = "center")
示例10: draw_rectangle
def draw_rectangle(x,y,width,height):
"""
Draws a rectangle with the upper left hand corner starting at point (x,y).
The said rectangle has the dimensions width x height.
:param x:
:param y:
:param width:
:param height:
:return: None
"""
turtle.penup()
turtle.setx(x)
turtle.sety(y)
turtle.pendown()
turtle.setheading(0) # Set heading in x+ direction
turtle.begin_fill()
turtle.begin_poly()
turtle.fd(width)
turtle.right(90)
turtle.fd(height)
turtle.right(90)
turtle.fd(width)
turtle.right(90)
turtle.fd(height)
turtle.end_poly()
turtle.end_fill()
return None
示例11: initialize_plot
def initialize_plot(self, positions):
self.positions = positions
self.minX = minX = min(x for x,y in positions.values())
maxX = max(x for x,y in positions.values())
minY = min(y for x,y in positions.values())
self.maxY = maxY = max(y for x,y in positions.values())
ts = turtle.getscreen()
if ts.window_width > ts.window_height:
max_size = ts.window_height()
else:
max_size = ts.window_width()
self.width, self.height = max_size, max_size
turtle.setworldcoordinates(minX-5,minY-5,maxX+5,maxY+5)
turtle.setup(width=self.width, height=self.height)
turtle.speed("fastest") # important! turtle is intolerably slow otherwise
turtle.tracer(False) # This too: rendering the 'turtle' wastes time
turtle.hideturtle()
turtle.penup()
self.colors = ["#d9684c","#3d658e","#b5c810","#ffb160","#bd42b3","#0eab6c","#1228da","#60f2b7" ]
for color in self.colors:
s = turtle.Shape("compound")
poly1 = ((0,0),(self.cell_size,0),(self.cell_size,-self.cell_size),(0,-self.cell_size))
s.addcomponent(poly1, color, "#000000")
turtle.register_shape(color, s)
s = turtle.Shape("compound")
poly1 = ((0,0),(self.cell_size,0),(self.cell_size,-self.cell_size),(0,-self.cell_size))
s.addcomponent(poly1, "#000000", "#000000")
turtle.register_shape("uncolored", s)
示例12: drawFins
def drawFins(size):
turtle.fillcolor("red")
turtle.setheading(90)
turtle.begin_fill()
turtle.forward(0.2*size)
turtle.left(120)
turtle.forward(0.6*size)
turtle.right(120)
turtle.forward(0.3*size)
turtle.right(40)
turtle.forward(0.8*size)
turtle.end_fill()
turtle.setheading(0)
turtle.begin_fill()
turtle.penup()
turtle.forward(size)
turtle.pendown()
turtle.begin_fill()
turtle.right(50)
turtle.forward(0.8*size)
turtle.right(40)
turtle.forward(0.3*size)
turtle.right(120)
turtle.forward(0.6*size)
turtle.end_fill()
示例13: drawP
def drawP(size):
turtle.setheading(90)
turtle.penup()
turtle.forward(size*1.5);
turtle.pendown()
turtle.forward(size*0.5);
drawSemi(size, direction="right", degrees=336, colour="black")
示例14: main
def main():
turtle.setup(800, 350, 200, 200)
turtle.penup()
turtle.fd(-300)
turtle.pensize(5)
drawDate(datetime.datetime.now().strftime('%Y%m%d'))
turtle.hideturtle()
示例15: main
def main():
file_name = "go"
file_name = raw_input( 'Enter a file name or exit to quit program: ')
while (file_name != "exit" and file_name != "Exit" and file_name != "quit" and file_name != "Quit"):
f = open( file_name, 'r' )
first_line = f.readline()
first_line = first_line.split()
distance = float( first_line[0] )
angle = float( first_line[1] )
stack = []
wn = tur.Screen()
for line in f:
wn.clear()
tur.penup()
tur.seth(90)
tur.setx(0)
tur.sety(-200)
tur.pendown()
interprit_line(tur, line, angle, distance, stack)
ts = tur.getscreen()
ts.getcanvas().postscript(file=file_name +".eps")
wn.exitonclick()
file_name = raw_input( 'Enter a file name or exit to quit program: ')