Draw a spiral in a box This geometric spiral looks complicated, but it's fairly simple to draw; take the following box:



Draw a straight line between the corner of the box and some set distance above the next corner counter-clockwise.



Continue this pattern inward, always staying that set distance away from the corner of the next line. Here's a few more lines in.



As you can see, as the pattern continues, the spiral approaches the center and the boxes you draw begin to rotate. Note that the distance remains constant, regardless of angle.

The Challenge

The Inspiration (and also thanks to the wonderful person who introduced me to this concept &lt;3)

Given a numerical (possibly fractional) input from 1 to 25, write an image to disk that uses this pattern or display the output on the screen, where the distance from each corner is the distance of one initial side of the box divided by the input. Continue the pattern inward until the distance from the corner specified is longer than the length of the next side.

Rules


You may not use built-ins for this spiral creation, but you may use image processing builtins.
If you write to disk, you must output an image in any of .jpg, .gif, .tiff, .pbm, .ppm, and .png.
The initial side length must be at least 500 pixels.
The initial corner may be whichever you choose.
As always, the Standard Loopholes are disallowed.
Shoes (Ruby) 163 bytes
Shoes is a ruby-based GUI toolkit.
Shoes.app{n=ask('').to_f
r=s=5E2
a=[0,s*i=&quot;i&quot;.to_c,s*i+s,s,0]
(q=a[-3]-a[-4]
r=q.abs/s*n
a&lt;&lt;a[-4]+q/r)while r&gt;1
1.upto(a.size-1){|j|line *(a[j-1].rect+a[j].rect)}}

Ungolfed
Shoes.app{ 
  n=ask('').to_f                 #Open a dialog box with no message, get n from user
  r=s=5E2                        #Initialize s to sidelength=500. r can be initialized to any vale, we use the same one for convenience.
  a=[0,s*i=&quot;i&quot;.to_c,s*i+s,s,0]   #intialize array a with 5 points needed to draw a square, in complex number format (first point=0 is duplicated.)

  (
    q=a[-3]-a[-4]                #find the vector from point plotted 4 before to the following point (plotted 3 before)
    r=q.abs/s*n                  #r is the scale factor
    a&lt;&lt;a[-4]+q/r                 #add a new point derived from a[-4] by moving toward a[-3] by a distance s/n 
  )while r&gt;1                     #break loop when length of line is less than s/n

  1.upto(a.size-1){|j|           #for all points except 1st and last one
    line *(a[j-1].rect+a[j].rect)#take the two complex numbers correspondimg to the current and previous point,
  }                              #convert to 2-element arrays (rectangular coordinates
}                                #combine to make a 4-element array, use * to splat into 4 parameters, and draw using the line method.

Outputs n=4 and n=25

Note that the shape always ends in a triangle, which collapses further to a line. Replacing size-1 with size makes no difference to the appearance of the output and would save 2 bytes, but I left it in for theoretical correctness.
Output n=300
Inspired by a comment by OP, the higher numbers do look great!