title: Creating Rounded Edges for a Polygon in Python
body: <p>I came across this interesting question (<a href="https://stackoverflow.com/questions/44099594/how-to-make-a-tkinter-canvas-rectangle-with-rounded-corners/61162928#61162928">How to make a tkinter canvas rectangle with rounded corners?</a>) related to creating rounded rectangles in Tkinter and specifically, this answer by Francisco Gomes (modified a bit):</p>
  <pre><code>def roundPolygon(x, y, sharpness):
  
      # The sharpness here is just how close the sub-points
      # are going to be to the vertex. The more the sharpness,
      # the more the sub-points will be closer to the vertex.
      # (This is not normalized)
      if sharpness &lt; 2:
          sharpness = 2
  
      ratioMultiplier = sharpness - 1
      ratioDividend = sharpness
  
      # Array to store the points
      points = []
  
      # Iterate over the x points
      for i in range(len(x)):
          # Set vertex
          points.append(x[i])
          points.append(y[i])
  
          # If it's not the last point
          if i != (len(x) - 1):
              # Insert submultiples points. The more the sharpness, the more these points will be
              # closer to the vertex. 
              points.append((ratioMultiplier*x[i] + x[i + 1])/ratioDividend)
              points.append((ratioMultiplier*y[i] + y[i + 1])/ratioDividend)
              points.append((ratioMultiplier*x[i + 1] + x[i])/ratioDividend)
              points.append((ratioMultiplier*y[i + 1] + y[i])/ratioDividend)
          else:
              # Insert submultiples points.
              points.append((ratioMultiplier*x[i] + x[0])/ratioDividend)
              points.append((ratioMultiplier*y[i] + y[0])/ratioDividend)
              points.append((ratioMultiplier*x[0] + x[i])/ratioDividend)
              points.append((ratioMultiplier*y[0] + y[i])/ratioDividend)
              # Close the polygon
              points.append(x[0])
              points.append(y[0])
  </code></pre>
  <p>When I adapted this code to work with my graphics library, it worked well enough! but when I create a 'stretched-square' (a non-square rectangle), the roundness becomes stretched too:</p>
  <p><a href="https://i.stack.imgur.com/2fwtx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2fwtx.png" alt="enter image description here" /></a></p>
  <p>So how can I change this code to remove the stretched roundness and keep it a constant radius?</p>