本文整理汇总了Python中turtle.right函数的典型用法代码示例。如果您正苦于以下问题:Python right函数的具体用法?Python right怎么用?Python right使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了right函数的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: initBannerCanvas
def initBannerCanvas( numChars, numLines ):
"""
Set up the drawing canvas to draw a banner numChars wide and numLines high.
The coordinate system used assumes all characters are 20x20 and there
are 10-point spaces between them.
Postcondition: The turtle's starting position is at the bottom left
corner of where the first character should be displayed.
"""
# This setup function uses pixels for dimensions.
# It creates the visible size of the canvas.
canvas_height = 80 * numLines
canvas_width = 80 * numChars
turtle.setup( canvas_width, canvas_height )
# This setup function establishes the coordinate system the
# program perceives. It is set to match the planned number
# of characters.
height = 30
width = 30 * numChars
margin = 5 # Add a bit to remove the problem with window decorations.
turtle.setworldcoordinates(
-margin+1, -margin+1, width + margin, numLines*height + margin )
turtle.reset()
turtle.up()
turtle.setheading( 90 )
turtle.forward( ( numLines - 1 ) * 30 )
turtle.right( 90 )
turtle.pensize( 2 * scale)
示例3: hang
def hang():
turtle.speed(0)
if stage[0]==0:
go_to(-300,0,0)
turtle.forward(600)
go_to(-100,0, 90)
turtle.forward(200)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(25)
elif stage[0]==1:
go_to(0, 150, 0)
turtle.circle(12.5)
elif stage[0]==2:
go_to(0,150, -90)
turtle.forward(50)
elif stage[0]==3:
go_to(0,140, -45)
turtle.forward(25)
go_to(0,140, -135)
turtle.forward(25)
elif stage[0]==4:
go_to(0,100, -45)
turtle.forward(25)
go_to(0,100, -135)
turtle.forward(25)
stage[0]+=1
return 0
示例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: draw_fractal4
def draw_fractal4(turtle, size):
for i in range(1,5):
for i in range(1,3):
draw_fractal3(turtle, size)
turtle.forward(size * 27)
turtle.forward(size * 27)
turtle.right(90)
示例6: demo
def demo():
turtle.forward(100)
turtle.left(120)
turtle.forward(80)
turtle.right(90)
turtle.forward(80)
turtle.exitonclick()
示例7: star
def star( x, y, scale, fill, color ):
'''draws a star given location, scale, and color'''
goto( x, y )
if fill == "True":
'''if the scale is 1, and fill == True
then this function will draw a star
with its left point at (x,y) and
will have star ray lengths of 50
and filled with the color given'''
t.begin_fill()
t.color(color)
for i in range(10):
t.forward(50*scale)
t.right(108)
t.forward(50*scale)
t.left(144)
t.end_fill()
else:
'''if the scale is 1, and fill == False
then this function will draw a star
with its left point at (x,y) and
will have star ray lengths of 50
and with no color fill'''
t.begin_fill()
for i in range(10):
t.forward(50*scale)
t.right(108)
t.forward(50*scale)
t.left(144)
示例8: draw_tree
def draw_tree(depth, height, branches, leafs, angle):
"""
Draws the tree using recursion
:pre: pos(0,0), heading east, up
:post: pos(0,0), heading east, up
:param depth: number of layers of sub branches (recursion depth)
:param height: height of tree
:param branches: number of branches
:param leafs: number of leafs
:param angle: angle between branches
:return: None
"""
if depth == 0:
leafs = random.randint(0, leafs)
draw_leaf(leafs)
t.down()
pass
else:
t.color('brown')
t.forward(height)
for i in range(1, branches+1):
t.left(90 - i * angle)
#random branches
branches = random.randint(branches-1,branches+5)
draw_tree(depth - 1, height * HEIGHT_FACTOR, branches, leafs, angle)
t.right(90 - i * angle)
#random angle
angle = random.randint(angle-1, angle+1)
if depth == 1:
break
t.color('brown')
t.backward(height)
示例9: draw_leaf
def draw_leaf(no_of_leafs):
"""
Draws leafs at the end of branch. Min 0 and max = no_of_leafs
:pre: pos(0,0), heading east, up
:post: pos(0,0), heading east, up
:param no_of_leafs: maximum number of leads drawn
:return: None
"""
for i in range(no_of_leafs):
# draws random poylgon from triangle to hexagon
sides = random.randint(3, 6)
color = random.choice(COLORS)
size = 10
angle = 360/sides
t.left(90 - i * angle)
t.right(90)
t.begin_fill()
t.down()
t.color(color)
for _ in range(sides):
t.forward(size)
t.left(angle)
t.left(90)
t.up()
t.end_fill()
t.right(90 - i * angle)
global LEAF_COUNTER
LEAF_COUNTER += 1
示例10: drawMyTree
def drawMyTree(trunk):
"""
Draws the tree of type MyTree
:pre: (relative) pos (0,0), heading (north), up
:post: (relative) pos (0,0), heading (north), up
:return: height of tree
"""
drawTrunk(trunk)
turtle.right(60)
turtle.forward(30)
turtle.left(60)
turtle.forward(60)
turtle.left(60)
turtle.forward(30)
turtle.left(60)
turtle.forward(30)
turtle.left(60)
turtle.forward(60)
turtle.left(60)
turtle.forward(30)
turtle.right(60)
turtle.forward(trunk)
turtle.left(90)
height = trunk + (30 * (3 ** 0.5) + 60)
return height
示例11: robber_move
def robber_move(turtle):
fifty_fifty = random.randrange(0, 2)
if fifty_fifty == 0:
turtle.right(90)
else:
turtle.left(90)
turtle.forward(10)
示例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: drawS
def drawS(length):
"""
Draw English character 'S'
:pre: (relative) pos (X,Y), heading (east), up
:post: (relative) pos (X+length,Y), heading (east), up
:return: None
"""
turtle.up()
turtle.left(90)
turtle.forward(length)
turtle.right(90)
turtle.down()
turtle.forward(length)
turtle.right(180)
turtle.forward(length)
turtle.left(90)
turtle.forward(length / 2)
turtle.left(90)
turtle.forward(length)
turtle.right(90)
turtle.forward(length / 2)
turtle.right(90)
turtle.forward(length)
turtle.right(180)
turtle.forward(length)
turtle.up()
示例14: y_tree
def y_tree(length = 200):
"""
This function receives a length and draws a tree according to the length
in an angle 60 between the branches always reducing the next length by
0.6. The drawing ends when the length is smaller than 10
:param length: The length of the branch to draw, default 200
:return: None
"""
ANGLE_BETWEEN_BRANCHES = 60
LENGTH_REDUCTION = 0.6
MIN_LENGTH = 10
if length <= MIN_LENGTH:
return
else:
turtle.forward(length) # draws the branch
turtle.left(ANGLE_BETWEEN_BRANCHES / 2)
y_tree(LENGTH_REDUCTION * length) # draws the left branch
turtle.right(ANGLE_BETWEEN_BRANCHES)
y_tree(LENGTH_REDUCTION * length) # draws the right branch
turtle.left(ANGLE_BETWEEN_BRANCHES / 2)
turtle.backward(length) # returns back to draw next
示例15: plano2d
def plano2d():
turtle.penup()
for i in range(13):
y = 264 - (44 *i)
turtle.penup()
turtle.setposition(-264,y)
turtle.pendown()
turtle.forward(528)
turtle.right(90)
for i in range(13):
x = -264 + (44*i)
turtle.penup()
turtle.setposition(x,264)
turtle.pendown()
turtle.forward(528)
turtle.penup()
turtle.home()
turtle.pendown()
turtle.color("blue")
turtle.pensize(3)
for i in range(4):
grados = 90 * (i+1)
turtle.home()
turtle.left(grados)
turtle.forward(264)