本文整理汇总了Python中turtle.down函数的典型用法代码示例。如果您正苦于以下问题:Python down函数的具体用法?Python down怎么用?Python down使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了down函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawCircle
def drawCircle(x, y, r):
turtle.up()
turtle.setpos(x+r,y)
turtle.down()
for i in range(0, DEGREES_IN_CIRCLE):
a = math.radians(i+1)
turtle.setpos(x+r*math.cos(a), y+r*math.sin(a))
示例2: choix_position
def choix_position(self):
#position aléatoire dans l'écran
self.x = random.randint(-350, 350)
self.y = random.randint(-350, 350)
tt.up()
tt.goto(self.x, self.y)
tt.down()
示例3: ejes
def ejes():
####################################
# Ejes Coordenados #
# los ejes x e y van de -150 a 150 #
####################################
turtle.delay(0)
turtle.ht()
turtle.speed(0)
turtle.pencolor('red')
turtle.down()
turtle.fd(301)
turtle.rt(90)
turtle.fd(1)
turtle.rt(90)
turtle.fd(300)
turtle.lt(90)
turtle.fd(300)
turtle.rt(90)
turtle.fd(1)
turtle.rt(90)
turtle.fd(300)
turtle.lt(90)
turtle.fd(300)
turtle.rt(90)
turtle.fd(1)
turtle.rt(90)
turtle.fd(300)
turtle.lt(90)
turtle.fd(300)
turtle.rt(90)
turtle.fd(1)
turtle.rt(90)
turtle.fd(300)
turtle.up()
turtle.pencolor('blue')
示例4: drawHouse
def drawHouse(wallSize):
"""
This is the function for drawing house which takes
wall size as a input.
:pre: (relative) pos (0,0), heading (east), right
:post: (relative) pos (wallSize,0), heading (north), up
:return: total wood required to built the house.
"""
turtle.down()
turtle.forward(wallSize)
turtle.left(90)
turtle.forward(wallSize)
maxX = turtle.xcor()
turtle.left(45)
turtle.forward(wallSize / math.sqrt(2))
maxY = turtle.ycor()
turtle.left(90)
turtle.forward(wallSize / math.sqrt(2))
turtle.left(45)
turtle.forward(wallSize)
turtle.left(90)
turtle.forward(wallSize)
turtle.up()
return 2 * (wallSize + wallSize / math.sqrt(2))
示例5: 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
示例6: questionMark
def questionMark():
""" Draw a question mark.
"""
scale = int(input("scale, integer please"))
turtle.forward( 10 *scale)
turtle.down()
turtle.left( 90 )
turtle.forward( 2 *scale)
turtle.up()
turtle.forward( 3 *scale)
turtle.down()
turtle.forward( 5 *scale)
turtle.right( 90 )
turtle.forward( 10 *scale)
turtle.left( 90 )
turtle.forward( 10 *scale)
turtle.left( 90 )
turtle.forward( 20 *scale)
turtle.left( 90 )
turtle.forward( 5 *scale)
turtle.up()
turtle.forward( 15 *scale)
turtle.left( 90 )
turtle.forward ( 30 *scale)
示例7: drawY
def drawY(length):
"""
Draw English character 'Y'
: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.right(45)
turtle.forward(math.sqrt((2 * math.pow((length / 2), 2))))
# moving at 45 degree angle for length sqrt(((math.pow((length/2)+(math.pow((length/2)),2)))
# calculated using pythagorean theorem.
turtle.right(45)
turtle.forward(length / 2)
turtle.right(180)
turtle.forward(length / 2)
turtle.right(45)
turtle.forward(math.sqrt((2 * math.pow((length / 2), 2))))
turtle.right(45)
turtle.up()
turtle.right(90)
turtle.forward(length)
turtle.left(90)
turtle.up()
示例8: tree1
def tree1(argv, x, y):
lsys_filename1 = argv[1]
lsys1 = ls.createLsystemFromFile( lsys_filename1 )
print lsys1
num_iter1 = int( 3 )
dist = float( 5 )
angle1 = float( 22 )
s1 = ls.buildString( lsys1, num_iter1 )
#draw lsystem1
'''this is my first lsystem
with filename mysystem1.txt
with 3 iterations and
with angle = 45 dist = 10'''
turtle.tracer(False)
turtle.speed(50000000)
turtle.up()
turtle.goto(0,0)
turtle.goto(x, y)
turtle.down()
turtle.pencolor('White')
it.drawString( s1, dist, angle1 )
# wait and update
turtle.update()
示例9: newSnow
def newSnow(size,n):
x=size/2
y=.4
if n<=0 or size<10:
return
else:
for i in range(2):
if n%2==0:
turtle.color("#0099CC")
elif n%3==0:
turtle.color("#B2DFEE")
else:
turtle.color("#00B2EE")
turtle.forward(y*size/2)
turtle.left(60)
newSnow(x,n-1)
turtle.right(120)
newSnow(x,n-1)
turtle.left(60)
x/=2
y+=.2
if n%2==0:
turtle.color("#0099CC")
elif n%3==0:
turtle.color("#B2DFEE")
else:
turtle.color("#00B2EE")
turtle.forward(.4*size/2)
turtle.up()
turtle.back(1.4*size/2)
turtle.down()
return
示例10: bezier
def bezier(smooth, x1, y1, x2, y2, x3, y3, *others):
if len(others) % 2 != 0:
print("Missing point data.")
return
if smooth < 1:
print("Invalid smooth value")
return
wasDown = turtle.isdown()
points = list(others)
xval = [x1, x2, x3] + points[0:len(points):2]
yval = [y1, y2, y3] + points[1:len(points):2]
t, n, factn, step = 0, len(xval) - 1, factoral(len(xval) - 1), 1.0/smooth
turtle.up()
turtle.goto(x1, y1)
if wasDown:
turtle.down()
while(t <= 1):
x, y = 0, 0
for i in range(0, n+1):
b = factn / ((factoral(i)) * (factoral(n - i))) #binomial coefficient
k = ((1 - t) ** (n - i)) * (t ** i) #powers
x += b * k * xval[i] #parametric application
y += b * k * yval[i] #to x and y
turtle.goto(x, y)
t += step
示例11: drawBorder
def drawBorder():
"""Draw a circle for the outline of the thingy. that is a circle of radius 100"""
turtle.right( 90 )
turtle.down()
turtle.circle( 100 )
turtle.up()
turtle.left( 90 )
示例12: questionMark
def questionMark(scale = 1):
""" Draw a question mark.
"""
turtle.up()
turtle.forward( 10 * scale )
turtle.down()
turtle.left( 90 )
turtle.forward( 2 * scale )
turtle.up()
turtle.forward( 3 * scale )
turtle.down()
turtle.forward( 5 * scale)
turtle.right( 90 )
turtle.forward( 10 * scale)
turtle.left( 90 )
turtle.forward( 10 * scale )
turtle.left( 90 )
turtle.forward( 20 * scale )
turtle.left( 90 )
turtle.forward( 5 * scale )
turtle.up()
turtle.forward( 15 * scale )
turtle.left( 90 )
turtle.forward ( 30 * scale )
示例13: sun
def sun(argv):
lsys_filename3 = argv[3]
lsys3 = ls.createLsystemFromFile( lsys_filename3 )
print lsys3
num_iter3 = int( 3 )
dist = 5
angle3 = float( 120 )
s3 = ls.buildString( lsys3, num_iter3 )
#draw lsystem3
'''this is my third lsystem
with filename mysystem3.txt
with 3 iterations and
with angle = 45 dist = 10'''
turtle.up()
turtle.goto(0,0)
turtle.goto(300, 200)
turtle.down()
turtle.setheading(0)
turtle.left(90)
turtle.pencolor('Red')
it.drawString( s3, dist, angle3 )
# wait and update
turtle.update()
示例14: tree2
def tree2(argv, x, y):
lsys_filename2 = argv[2]
lsys2 = ls.createLsystemFromFile( lsys_filename2 )
print lsys2
num_iter2 = int( 3 )
dist = float( 5 )
angle2 = float( 30 )
s2 = ls.buildString( lsys2, num_iter2 )
#draw lsystem2
'''this is my second lsystem
with filename mysystem2.txt
with 5 iterations and
with angle = 120 dist = 10'''
turtle.up()
turtle.goto(0,0)
turtle.goto(x,y)
turtle.down()
turtle.setheading(0)
turtle.left(90)
turtle.pencolor('White')
it.drawString( s2, dist, angle2 )
# wait and update
turtle.update()
示例15: hexagone
def hexagone(c, longueur,m, col1, col2, col3,deform):
"""
Draws a hexagon with or without deformation
"""
lo = longueur
x,y,z = c #Hexagon centre
pa1,pa2,pa3 = (x+lo,y,z), (x+(lo/2),y-m,z), (x-(lo/2),y-m,z)#First losange coordinates (lower right)
pb1,pb2,pb3 = (x+lo,y,z), (x+(lo/2),y+m,z), (x-(lo/2),y+m,z)#Losange 2 (upper right)
pc1,pc2,pc3 = (x-(lo/2),y+m,z), (x-lo,y,z), (x-(lo/2),y-m,z)#Losange 3 (left)
pts = [pa1,pa2,pa3,c,pb1,pb2,pb3,c,pc1,pc2,pc3,c]
d = []
for point in pts:
xd,yd,zd = deform(point)
d.extend((xd,yd))
up()
setpos(d[6],d[7])#Turtle resets to c
down()
col = [col1,col2,col3]
i = 0
for e in col:
color(e)
begin_fill()
goto(d[i],d[i+1])
goto(d[i+2],d[i+3])
goto(d[i+4],d[i+5])
goto(d[i+6],d[i+7])
end_fill()
i += 8