title: Scale polygons by a ratio using only a list of their vertices
body: <p>In my program, users can draw shapes atop a matplotlib plot and do various actions with those shapes. I'm currently trying to implement scaling of these shapes to maintain their location in reference to the main plot, even when zoomed in. </p>
  
  <hr>
  
  <p>My objects are represented by a list of vertices,</p>
  
  <pre><code>obj = [(1, 1), (2, 1), (1, 0), (2, 0)] # represents a 1 unit square
  </code></pre>
  
  <p>of course this is a simplified breakdown of how my polygons are represented, but the only useful attribute of them in this case is the vertices.</p>
  
  <hr>
  
  <p>The User can select a bounding box of where he would like to zoom in, shown below</p>
  
  <p><img src="https://i.stack.imgur.com/FGrHU.png" alt="enter image description here"></p>
  
  <p>Once the mouse is released the application will zoom to that location, the only problem is my polygons do not zoom with this. While the canvas is zoomed, the polygons will remain in their exact location and now represent a whole different area than they did before. This is because the zoom is handled by matplotlib, which is a backend to the actual application. what I would <strong>like</strong> to do is along the lines of what the picture shows below if the user were to zoom in on the selected location above: 
  <img src="https://i.stack.imgur.com/nCsJp.png" alt="enter image description here"></p>
  
  <p>So what I do know is</p>
  
  <ul>
  <li>The list of vertices of the object <code>[(1,2),(1,0)....]</code></li>
  <li>A list of handles to all objects contained inside the bounded zoom <code>targets = [itemHandle1, itemHandle2....]</code></li>
  <li>The location of the bounded zoom box via the topleft and bottom right coordinate e.g. <code>zoomboundedbox = [(162, 62), (937, 560)]</code></li>
  </ul>
  
  <p>I believe I know all the required data about my objects to scale these objects correctly, but I don't know the <em>algorithm</em> that will allow me to accomplish this ...</p>
  
  <pre><code>def receive(self, lim):
  '''
  Calculate new coordinates of polygons visible to screen, this function
  is called when the user releases the mouse button on the zoom function,
  the parameters of the bounding box are internally stored as (x,y) tuples
  in xyf (x,y first) and xyl (x,y last)
  '''
  
      # Grab all item handles to polygons that intersect with the zoom
      # Stored in `targets`
  
      for shape in self.activePolygonList:         # loop through active polygons on screen
          if shape.handle() in targets:            # if the polygon is a target to be scaled
              print "scaling...."
              # ?                                   
              shape.redrawShape()
  </code></pre>