chiark / gitweb /
Extract code to emit a single contour from emit_path().
authorBen Harris <bjh21@bjh21.me.uk>
Tue, 8 Aug 2017 21:25:05 +0000 (22:25 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Tue, 8 Aug 2017 21:25:05 +0000 (22:25 +0100)
I want to make emit_path() more complex, so pulling out this obvious
unit seems wise.

bedstead.c

index ede53e4784a6c02462aeab83f087bdfa61e99426..f34f14dd8ea0fa3e8c98caeecd36afcca6275f23 100644 (file)
@@ -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");