diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-01-13 18:01:44 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-01-13 18:01:44 -0800 |
commit | 180dd57af67d8176819ea8ff322c315d8425c9cf (patch) | |
tree | 683c8951098ae2eca6803e523acb9a9e0e3e4d27 | |
parent | 6e7a7fca8268b4c65e22122f8987da2f0e747754 (diff) | |
download | pesconvert-180dd57af67d8176819ea8ff322c315d8425c9cf.tar.gz |
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>
-rw-r--r-- | cairo.c | 6 | ||||
-rw-r--r-- | main.c | 7 | ||||
-rw-r--r-- | pes.h | 2 |
3 files changed, 11 insertions, 4 deletions
@@ -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 @@ void output_cairo(struct pes *pes, const char *filename, int size) ++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; @@ -23,6 +23,7 @@ static void die(const char *fmt, ...) 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 @@ int main(int argc, char **argv) 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 @@ int main(int argc, char **argv) if (!output) die("Need a png output file name\n"); - output_cairo(&pes, output, outputsize); + output_cairo(&pes, output, outputsize, density); return 0; } @@ -36,6 +36,6 @@ int parse_pes(struct region *region, struct pes *pes); /* 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 */ |