当前位置: 首页>>代码示例>>Python>>正文


Python turtle.up函数代码示例

本文整理汇总了Python中turtle.up函数的典型用法代码示例。如果您正苦于以下问题:Python up函数的具体用法?Python up怎么用?Python up使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了up函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: 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()
开发者ID:akaralekas,项目名称:cs151-colby,代码行数:26,代码来源:scene.py

示例2: main

def main():
	'''Creates lsystem from filename and then creates an arrangement'''
	# creates object from lsystem
	l = ls.Lsystem('lsystemextension2.txt')
	
	#number of iterations
	# for growth effect in task 3, made iters a parameter
	num_iter = 4
	
	
	# creates buildstring function
	s = l.buildString(num_iter)
	
	#specific angle
	angle = 30
	
	#creates an object from TI class
	ti = it.TurtleInterpreter()
	
	# sets the colors of the tracer and calls the drawstring function
	turtle.pencolor('ForestGreen')
	'''tree with stem color of forestgreen'''
	turtle.up()
	turtle.setposition(0,0)
	turtle.setheading(90)
	turtle.down()
	ti.drawString(s, 50 ,angle)
	
	
	
	ti.hold()
开发者ID:akaralekas,项目名称:cs151-colby,代码行数:31,代码来源:project8extension2.py

示例3: 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)
开发者ID:jonobrien,项目名称:School_Backups,代码行数:29,代码来源:spell_out.py

示例4: f

def f(l, n):
	t.up()
	t.goto( - l / 2, l / 3 )
	t.down()
	for i in rang(3):
		vk(l, n)
		t.right(120)
开发者ID:richardjuan,项目名称:nmt,代码行数:7,代码来源:vonKoch.py

示例5: line

def line(a, b, x, y):
    "Draw line from `(a, b)` to `(x, y)`."
    import turtle
    turtle.up()
    turtle.goto(a, b)
    turtle.down()
    turtle.goto(x, y)
开发者ID:grantjenks,项目名称:free_python_games,代码行数:7,代码来源:utils.py

示例6: draw_triangle

def draw_triangle(point1, point2, point3):
    turtle.up()
    turtle.goto(point1)
    turtle.down()
    turtle.goto(point2)
    turtle.goto(point3)
    turtle.goto(point1)
开发者ID:xzy3,项目名称:jormungard,代码行数:7,代码来源:Sierpinski.py

示例7: 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))
开发者ID:RIT-2015,项目名称:CPS,代码行数:25,代码来源:new_draw.py

示例8: linha

def linha(x1,y1,x2,y2):
    """ Traça uma linha entre dois pontos."""
    turtle.up()
    turtle.goto(x1,y1)
    turtle.pd()
    turtle.goto(x2,y2)
    turtle.up()
开发者ID:ernestojfcosta,项目名称:IPRP,代码行数:7,代码来源:graficos_2.py

示例9: tSquare

def tSquare(size, level):
    """ The T-Square fractal.
    http://en.wikipedia.org/wiki/T-Square_%28fractal%29
    """

    if level < 1:
        drawSquare(size, True)
    else:
        drawSquare(size, True)
        bk(size / 4.0)
        left(90)
        fd(size / 4.0)
        right(90)
        tSquare(size / 2.0, level - 1)
        up()
        fd(size)
        down()
        tSquare(size / 2.0, level - 1)
        right(90)
        fd(size)
        left(90)
        tSquare(size / 2.0, level - 1)
        bk(size)
        tSquare(size / 2.0, level - 1)
        left(90)
        up()
        fd(size * 3 / 4.0)
        down()
        right(90)
        fd(size / 4.0)
开发者ID:peterasujan,项目名称:fractals,代码行数:30,代码来源:fractals.py

示例10: 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()
开发者ID:akaralekas,项目名称:cs151-colby,代码行数:26,代码来源:project7extension.py

示例11: 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
开发者ID:wish343,项目名称:Python,代码行数:32,代码来源:SnowFlake.py

示例12: 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 )
开发者ID:dxa4481,项目名称:RITprojects,代码行数:7,代码来源:homeworkone.py

示例13: 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
开发者ID:rayman456,项目名称:Python,代码行数:26,代码来源:GraphicsFunctions.py

示例14: 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()
开发者ID:akaralekas,项目名称:cs151-colby,代码行数:27,代码来源:scene.py

示例15: roach

def roach(turt):
    #make moves a global variable
    global moves
    turt.pencolor(randrange(255),randrange(255),randrange(255))
    turtle.up()
    turtle.goto(0,0)
    turtle.down()
    #write the code for roach to go & turn
    while True:
        moves += 1
        turt_heading = randrange(0,361)
        turt.left(turt_heading)
        turt_length = randrange(0,31)
        turt.forward(turt_length)
        distance = dist(turt)
        #if statement to determine if the roach is outside the circle or inside
        #if inside, keep moving
        #if outside, stop moving
        #return coordinate
        if distance >= 200:
            break
    turt.up()
    moves += moves                      #accummulate total moves
    print(moves)
    return moves
开发者ID:khoanguyen0791,项目名称:cs170,代码行数:25,代码来源:Roach+Race+2.py


注:本文中的turtle.up函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。