Add a 'density' argument for thread thickness
I like the default thin thread effect, but using a density of 2.5 or so
seems to be a bit more realistic on my test-case. Which may be more
about the test-case than anything else, but whatever.
So with this, you can do something like
pesconvert -d 2.5 -s 512 Jan_heartsdelight.pes s512.png
to generate a 512-pixel sized version of the Brother example file.
Making the "thread" thicker also meant that the line join matters a lot
more. A miter join (the cairo default) is not how thread works and
makes it all look very jagged. So make it use a round join instead.
The line cap could probably be a butt cap, but I set it to round too. I
doubt anybody will see any difference, since thread ends aren't common.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
diff --git a/cairo.c b/cairo.c
index bd4d3d3..c7d6565 100644
--- a/cairo.c
+++ b/cairo.c
@@ -5,7 +5,7 @@
#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)
+void output_cairo(struct pes *pes, const char *filename, int size, double density)
{
int width = pes->max_x - pes->min_x, outw;
int height = pes->max_y - pes->min_y, outh;
@@ -37,7 +37,9 @@
++stitch;
cairo_line_to(cr, X(stitch), Y(stitch));
}
- cairo_set_line_width(cr, scale);
+ cairo_set_line_width(cr, scale * density);
+ cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
+ cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND);
cairo_stroke(cr);
block = block->next;
diff --git a/main.c b/main.c
index e9731da..57cddf7 100644
--- a/main.c
+++ b/main.c
@@ -23,6 +23,7 @@
int main(int argc, char **argv)
{
+ double density = 1.0;
int i, outputsize = -1;
const char *output = NULL;
struct region region;
@@ -43,6 +44,10 @@
outputsize = atoi(argv[i+1]);
i++;
continue;
+ case 'd':
+ density = atof(argv[i+1]);
+ i++;
+ continue;
}
die("Unknown argument '%s'\n", arg);
}
@@ -70,7 +75,7 @@
if (!output)
die("Need a png output file name\n");
- output_cairo(&pes, output, outputsize);
+ output_cairo(&pes, output, outputsize, density);
return 0;
}
diff --git a/pes.h b/pes.h
index 1030475..322cd7e 100644
--- a/pes.h
+++ b/pes.h
@@ -36,6 +36,6 @@
/* Output */
void output_svg(struct pes *pes);
void output_png(struct pes *pes);
-void output_cairo(struct pes *pes, const char *filename, int size);
+void output_cairo(struct pes *pes, const char *filename, int size, double density);
#endif /* PES_H */