From: Ben Harris Date: Tue, 8 Aug 2017 22:23:55 +0000 (+0100) Subject: Emit open contours starting at the beginning. X-Git-Tag: bedstead-002.000~74 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=051d1c662ca543127ec5602a89811732eb8effad;p=bedstead.git Emit open contours starting at the beginning. Before this change, emit_path() would emit contours starting at whichever point was earliest in the points array. That was fine for closed contours, but it meant the open contours tended to be emitted in multiple parts. Now it first searches for start points of open contours and emits those, and then does what it used to do to emit the remaining (closed) ones. This has no effect (other than to slow things down a bit) for fully-closed paths like those in outline versions of Bedstead, but it makes the stroked ones much cleaner. Now a contour can only end at a tip or at a 3-way junction. --- diff --git a/bedstead.c b/bedstead.c index 47b9469..9bfad09 100644 --- a/bedstead.c +++ b/bedstead.c @@ -1978,16 +1978,22 @@ emit_contour(point *p0) static void emit_path() { - int i; + int i, pass; point *p, *p1; bool started = false; - for (i = 0; i < nextpoint; i++) { - p = &points[i]; - if (p->next) { - if (!started) printf("Fore\nSplineSet\n"); - started = true; - emit_contour(p); + /* + * On the first pass, emit open contours (if there are any). + * On the second pass, emit all remaining contours. + */ + for (pass = 0; pass <= 1; pass++) { + for (i = 0; i < nextpoint; i++) { + p = &points[i]; + if (p->next && (!p->prev || pass == 1)) { + if (!started) printf("Fore\nSplineSet\n"); + started = true; + emit_contour(p); + } } } if (started) printf("EndSplineSet\n");