Fix some trivial scaling problems

I used to scale everything to be square.  That was fine for testing, but
not so great for actual use.  This makes it all look better when the
input isn't square.  It also scales the width of the line properly.

And in honor of this actually being useful (it's installed on Tove's
machine now), let's sign off on it all.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
diff --git a/cairo.c b/cairo.c
index 01b4441..bd4d3d3 100644
--- a/cairo.c
+++ b/cairo.c
@@ -2,24 +2,26 @@
 
 #include "pes.h"
 
-#define X(stitch) ((double)((stitch)->x - pes->min_x) * outw / width)
-#define Y(stitch) ((double)((stitch)->y - pes->min_y) * outh / height)
+#define X(stitch) (((stitch)->x - pes->min_x) * scale)
+#define Y(stitch) (((stitch)->y - pes->min_y) * scale)
 
 void output_cairo(struct pes *pes, const char *filename, int size)
 {
-	int width  = pes->max_x - pes->min_x + 1;
-	int height = pes->max_y - pes->min_y + 1;
-	int outw = width, outh = height;
+	int width  = pes->max_x - pes->min_x, outw;
+	int height = pes->max_y - pes->min_y, outh;
+	double scale = 1.0;
 	struct pes_block *block;
 	cairo_surface_t *surface;
 	cairo_t *cr;
 
 	if (size > 0) {
-		outw = size;
-		outh = size;
+		int maxd = width > height ? width : height;
+		scale = (double) size / maxd;
 	}
+	outw = width * scale;
+	outh = height * scale;
 
-	surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, outw, outh);
+	surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, outw+1, outh+1);
 	cr = cairo_create (surface);
 
 	block = pes->blocks;
@@ -35,7 +37,7 @@
 			++stitch;
 			cairo_line_to(cr, X(stitch), Y(stitch));
 		}
-		cairo_set_line_width (cr, 0.2);
+		cairo_set_line_width(cr, scale);
 		cairo_stroke(cr);
 
 		block = block->next;