From: Ben Harris Date: Tue, 8 Aug 2017 21:25:05 +0000 (+0100) Subject: Extract code to emit a single contour from emit_path(). X-Git-Tag: bedstead-002.000~76 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=bc10355aa50d15668a265409468e41e3d672d253;p=bedstead.git Extract code to emit a single contour from emit_path(). I want to make emit_path() more complex, so pulling out this obvious unit seems wise. --- diff --git a/bedstead.c b/bedstead.c index ede53e4..f34f14d 100644 --- a/bedstead.c +++ b/bedstead.c @@ -1959,6 +1959,22 @@ clean_path() } while (done_anything); } +static void +emit_contour(point *p0) +{ + point *p = p0, *p1; + + do { + printf(" %g %g %s 1\n", + (double)p->v.x / XSCALE, + (double)p->v.y / YSCALE - 3*YPIX, + p == p0 && p->next ? "m" : "l"); + p1 = p->next; + p->prev = p->next = NULL; + p = p1; + } while (p); +} + static void emit_path() { @@ -1970,15 +1986,7 @@ emit_path() if (p->next) { if (!started) printf("Fore\nSplineSet\n"); started = 1; - do { - printf(" %g %g %s 1\n", - (double)p->v.x / XSCALE, - (double)p->v.y / YSCALE - 3*YPIX, - p == &points[i] && p->next ? "m" : "l"); - p1 = p->next; - p->prev = p->next = NULL; - p = p1; - } while (p); + emit_contour(p); } } if (started) printf("EndSplineSet\n");