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.
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");