• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python turtle.setworldcoordinates函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: regression

def regression():
    filename = input("Please provide the name of the file including the extention: ")
    while not (os.path.exists(filename)):
        filename = input("Please provide a valid name for the file including the extention: ")
    ds = []
    file = open(filename)

    for line in file:
        coordinates = line.split()
        x = float(coordinates[0])
        y = float(coordinates[1])
        point = (x, y)
        ds.append(point)
    my_turtle = turtle.Turtle()
    turtle.title("Least Squares Regression Line")

    turtle.clearscreen()
    xmin = min(getXcoords(ds))
    xmax = max(getXcoords(ds))
    ymin = min(getYcoords(ds))
    ymax = max(getYcoords(ds))
    xborder = 0.2 * (xmax - xmin)
    yborder = 0.2 * (ymax - ymin)
    turtle.setworldcoordinates(xmin - xborder, ymin - yborder, xmax + xborder, ymax + yborder)
    plotPoints(my_turtle, ds)
    m, b = leastSquares(ds)
    print("The equation of the line is y=%fx+%f" % (m, b))
    plotLine(my_turtle, m, b, xmin, xmax)
    plotErrorBars(my_turtle, ds, m, b)
    print("Goodbye")
开发者ID:nathnael2,项目名称:PythonPrograms,代码行数:30,代码来源:FileLinearRegression.py


示例2: plot

	def plot(self, node1, node2, debug=False):
		"""Plots wires and intersection points with python turtle"""
		tu.setup(width=800, height=800, startx=0, starty=0)
		tu.setworldcoordinates(-self.lav, -self.lav, self.sample_dimension+self.lav, self.sample_dimension+self.lav)
		tu.speed(0)
		tu.hideturtle()
		for i in self.index:
			if debug:
				time.sleep(2)   # Debug only
			tu.penup()
			tu.goto(self.startcoords[i][0], self.startcoords[i][1])
			tu.pendown()
			tu.goto(self.endcoords[i][0], self.endcoords[i][1])
		tu.penup()
		if self.list_of_nodes is None:
			intersect = self.intersections(noprint=True)
		else:
			intersect = self.list_of_nodes
		tu.goto(intersect[node1][0], intersect[node1][1])
		tu.dot(10, "blue")
		tu.goto(intersect[node2][0], intersect[node2][1])
		tu.dot(10, "blue")
		for i in intersect:
			tu.goto(i[0], i[1])
			tu.dot(4, "red")
		tu.done()
		return "Plot complete"
开发者ID:jzmnd,项目名称:nw-network-model,代码行数:27,代码来源:nwnet.py


示例3: drawSetup

def drawSetup(title,xlimits,xscale,ylimits,yscale,axisThickness=None):
	turtle.title(title)
	xmin, xmax = xlimits
	ymin, ymax = ylimits
	#turtle.setup(xmax-xmin,ymax-ymin,0,0) #window-size
	globals()['xmin'] = xmin
	globals()['xmax'] = xmax
	globals()['ymin'] = ymin
	globals()['ymax'] = ymax
	globals()['xscale'] = xscale
	globals()['yscale'] = yscale

	turtle.setworldcoordinates(xmin,ymin,xmax,ymax)
	#turtle.speed(0) #turtle.speed() does nothing w/ turtle.tracer(0,0)
	turtle.tracer(0,0)

	drawGrid()
	#drawGridBorder()
	
	turtle.pensize(axisThickness)

	drawXaxis()
	drawXtickers()
	numberXtickers()
	
	drawYaxis()
	drawYtickers()
	numberYtickers()

	turtle.pensize(1)
开发者ID:Cacharani,项目名称:Graph-Kit,代码行数:30,代码来源:graphkit.py


示例4: __init__

 def __init__(self, T, lmbda, mu, speed=6, costofbalking=False):
     ##################
     bLx = -10 # This sets the size of the canvas (I think that messing with this could increase speed of turtles)
     bLy = -110
     tRx = 230
     tRy = 5
     setworldcoordinates(bLx,bLy,tRx,tRy)
     qposition = [(tRx+bLx)/2, (tRy+bLy)/2]  # The position of the queue
     ##################
     self.costofbalking = costofbalking
     self.T = T
     self.completed = []
     self.balked = []
     self.lmbda = lmbda
     self.mu = mu
     self.players = []
     self.queue = Queue(qposition)
     self.queuelengthdict = {}
     self.server = Server([qposition[0] + 50, qposition[1]])
     self.speed = max(0,min(10,speed))
     self.naorthreshold = False
     if type(costofbalking) is list:
         self.naorthreshold = naorthreshold(lmbda, mu, costofbalking[1])
     else:
         self.naorthreshold = naorthreshold(lmbda, mu, costofbalking)
     self.systemstatedict = {}
开发者ID:ByronKKing,项目名称:Simulating_Queues,代码行数:26,代码来源:graphicalMM1.py


示例5: init

def init():
    t.setworldcoordinates(0,0,
        WINDOW_WIDTH, WINDOW_HEIGHT)
    t.up()
    t.setheading(90)
    t.forward(75)
    t.title('Typography:Name')
开发者ID:krishRohra,项目名称:PythonAssignments,代码行数:7,代码来源:typography.py


示例6: __init__

 def __init__(self, world_size, beacons):
     self.beacons = beacons
     self.width = int(world_size)
     self.height = int(world_size)
     turtle.setworldcoordinates(0, 0, self.width, self.height)
     self.update_cnt = 0
     self.one_px = float(turtle.window_width()) / float(self.width) / 2
开发者ID:shreeshga,项目名称:gaussian_particlefilter,代码行数:7,代码来源:draw.py


示例7: SCREEN

    def SCREEN( self, mode ):
        """
        SCREEN 0 ● Text mode only

        SCREEN 1 ● 320 × 200 pixel medium-resolution graphics ● 80 x 25 text

        SCREEN 2 ● 640 × 200 pixel high-resolution graphics ● 40 × 25 text

        SCREEN 7 ● 320 × 200 pixel medium-resolution graphics ● 40 × 25 text

        SCREEN 8 ● 640 × 200 pixel high-resolution graphics ● 80 × 25 text

        SCREEN 9 ● 640 × 350 pixel enhanced-resolution graphics ● 80 × 25 text

        SCREEN 10 ● 640 × 350 enhanced-resolution graphics ● 80 × 25 text
        """
        if mode == 8:
            # Officially 640x200 with rectangular pixels, appears as 640x480.
            turtle.setup( width=640, height=480 )
            turtle.setworldcoordinates(0,0,640,480)
            self.aspect_v = (200/640)*(4/3)
        elif mode == 9:
            # Official 640x350 with rectangular pixels, appears 640x480.
            turtle.setup( width=640, height=480 )
            turtle.setworldcoordinates(0,0,640,480)
            self.aspect_v = (350/640)*(4/3)
开发者ID:slott56,项目名称:HamCalc-2.1,代码行数:26,代码来源:gwgraphics.py


示例8: 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)
开发者ID:jorgenkg,项目名称:IT3105,代码行数:34,代码来源:visuals.py


示例9: main

def main():
  ap = ArgumentParser()
  ap.add_argument('--speed', type=int, default=10,
                  help='Number 1-10 for drawing speed, or 0 for no added delay')
  ap.add_argument('program')
  args = ap.parse_args()

  for kind, number, path in parse_images(args.program):
    title = '%s #%d, path length %d' % (kind, number, path.shape[0])
    print(title)
    if not path.size:
      continue
    pen_up = (path==0).all(axis=1)
    # convert from path (0 to 65536) to turtle coords (0 to 655.36)
    path = path / 100.
    turtle.title(title)
    turtle.speed(args.speed)
    turtle.setworldcoordinates(0, 655.36, 655.36, 0)
    turtle.pen(shown=False, pendown=False, pensize=10)
    for i,pos in enumerate(path):
      if pen_up[i]:
        turtle.penup()
      else:
        turtle.setpos(pos)
        turtle.pendown()
        turtle.dot(size=10)
    _input('Press enter to continue')
    turtle.clear()
  turtle.bye()
开发者ID:perimosocordiae,项目名称:pyhrm,代码行数:29,代码来源:extract_images.py


示例10: 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


示例11: __init__

	def __init__(self, mazeFileName):
		rowsInMaze = 0
		columnsInMaze = 0
		self.mazelist = []
		mazeFile = open(mazeFileName, 'r')
		for line in mazeFile:
			rowList = []
			col = 0
			for ch in line[:-1]:
				rowList.append(ch)
				if ch == 'S':
					self.startRow = rowsInMaze
					self.startCol = col
				col = col + 1
			rowsInMaze = rowsInMaze + 1
			self.mazelist.append(rowList)
			columnsInMaze = len(rowList)

		self.rowsInMaze = rowsInMaze
		self.columnsInMaze = columnsInMaze
		self.xTranslate = -columnsInMaze / 2
		self.yTranslate = rowsInMaze / 2

		self.t = turtle.Turtle()
		self.t.shape('turtle')
		self.wn = turtle.Screen()
		turtle.setup(width = 600, height = 600)
		turtle.setworldcoordinates(-(columnsInMaze - 1)/2 - .5,
											  -(rowsInMaze - 1) / 2 - .5,
											  (columnsInMaze - 1)/ 2 + .5,
											  (rowsInMaze - 1) / 2 + .5 )
开发者ID:TianbinJiang,项目名称:LeetCode,代码行数:31,代码来源:maze.py


示例12: init_board

def init_board():
    board = turtle.Turtle()
    wn = turtle.Screen()
    turtle.setworldcoordinates(-400,-400,400,400)
    wn.bgcolor('green')
    board.ht()
    board.speed(0)
    board.pensize(4)
    board.pencolor('black')

    coordinate = [[-300,-400,90,None,800],
		  [-200,-400,None,None,800],
		  [-100,-400,None,None,800],
		  [0,-400,None,None,800],
		  [100,-400,None,None,800],
		  [200,-400,None,None,800],
		  [300,-400,None,None,800],
		  [-400,-300,None,90,800],
		  [-400,-200,None,None,800],
		  [-400,-100,None,None,800],
		  [-400,0,None,None,800],
		  [-400,100,None,None,800],
		  [-400,200,None,None,800],
		  [-400,300,None,None,800]]
		  
    for i in range(14):
        X=0
        Y=1
        LEFT=2
        RIGHT=3
        FORWARD=4
开发者ID:TylerGillson,项目名称:cpsc-reversi,代码行数:31,代码来源:Reversi_Master.py


示例13: initBannerCanvas

def initBannerCanvas( numChars , numLines, scale ):
    """
    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.
    Precondition: The initial canvas is default size, then input by the first
    two user inputs, every input after that defines each letter's scale, probably between
    1 and 3 for the scale values to have the window visible on the screen.
    Postcondition: The turtle's starting position is at the bottom left
    corner of where the first character should be displayed, the letters are printed.
    """
    scale = int(input("scale, integer please"))
    
    # This setup function uses pixels for dimensions.
    # It creates the visible size of the canvas.
    canvas_height = 80 * numLines *scale
    canvas_width = 80 * numChars *scale
    turtle.setup( canvas_width *scale, canvas_height *scale)

    # This setup function establishes the coordinate system the
    # program perceives. It is set to match the planned number
    # of characters.
    height = 30 *scale
    width = 30 * numChars *scale
    margin = 5 # Add a bit to remove the problem with window decorations.
    turtle.setworldcoordinates(
        -margin+1 * scale, -margin+1 * scale, width + margin* scale, numLines*height + margin * scale)

    turtle.reset()
    turtle.up()
    turtle.setheading( 90 )
    turtle.forward( ( numLines - 1 ) * 30 )
    turtle.right( 90 )
    turtle.pensize( 1  *scale)
开发者ID:jonobrien,项目名称:School_Backups,代码行数:34,代码来源:spell_out.py


示例14: init

def init():
    """
    sets the window size and the title of the program
    """
    t.setworldcoordinates(0, 0, WINDOW_LENGTH, WINDOW_HEIGHT)
    t.title('Forest')
    t.up()
    t.forward(100)
开发者ID:krishRohra,项目名称:PythonAssignments,代码行数:8,代码来源:forest.py


示例15: __init__

    def __init__(self, dim_x, dim_y, maze):
        # 'maze' is a list of pairs of points, which represent the endpoints
        # of each line segment.
        self.maze = maze

        self.dim_x = dim_x
        self.dim_y = dim_y

        turtle.setworldcoordinates(0, 0, self.dim_x, self.dim_y)
        self.update_cnt = 0
开发者ID:ralfgunter,项目名称:nxt-montecarlo,代码行数:10,代码来源:draw.py


示例16: init

def init():
    turtle.setworldcoordinates(-WINDOW_WIDTH / 2, -WINDOW_WIDTH / 2,
                               WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2)
    turtle.up()
    turtle.setheading(0)
    turtle.hideturtle()
    turtle.title('Snakes')
    turtle.showturtle()
    turtle.setx(-225)
    turtle.speed(0)
开发者ID:yj29,项目名称:PythonAssignments,代码行数:10,代码来源:typography.py


示例17: init

def init():
    """
    Initialize the canvas
    :pre: relative (0,0), heading east, up
    :post: relative (0,0), heading east, up
    :return: None
    """
    t.setworldcoordinates(-BOUNDARY/2, -BOUNDARY/2, BOUNDARY, BOUNDARY)
    t.title("SQUARES")
    t.speed(0)
开发者ID:AnushaBalusu,项目名称:PythonCodes,代码行数:10,代码来源:square.py


示例18: drawcurve

def drawcurve(points):
    myTurtle = turtle.Turtle(shape="turtle")
    turtle.screensize(500,500)
    turtle.setworldcoordinates(400,400,500,500)
    myTurtle.penup()
    y = points[0]
    myTurtle.setposition(y[0], y[1])
    myTurtle.pendown()
    for x in points:
        myTurtle.setposition(x[0], x[1])
    turtle.getscreen()._root.mainloop()
开发者ID:mmercedes,项目名称:18-549,代码行数:11,代码来源:pi2c.py


示例19: _init

def _init():
    root = Tk()
    menubar = Menu(root)
    menubar.add_command(label="Save", command=save_image) 
    menubar.add_command(label="Clear", command=_clear)
    root.config(menu=menubar)
    turtle.speed(0)
    turtle.delay(0)
    turtle.setworldcoordinates(-xCoor,-yCoor,xCoor,yCoor)
    turtle.up()
    turtle.setpos(0,0)
    turtle.down()
开发者ID:hcwndbyw,项目名称:12_turtles,代码行数:12,代码来源:runner.py


示例20: __init__

    def __init__(self):
        #Creates display for visualization. 
        self.window = turtle.Screen()
        turtle.setworldcoordinates(-5, -5, 5, 5)
        turtle.speed(0)

        #Initializes ROS and subscribes to particle filter. 
        rospy.init_node('particle_visualizer', anonymous=True)
        rospy.Subscriber('particle_filter', Particle_vector, self.update)

        #Initializes list of particles. 
        self.particles = []
开发者ID:rcorona,项目名称:particle_filter,代码行数:12,代码来源:particle_visualizer.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python turtle.shape函数代码示例发布时间:2022-05-27
下一篇:
Python turtle.setup函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap