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.
This commit is contained in:
Ben Harris 2017-08-08 22:25:05 +01:00
parent bfd3fbdbf7
commit bc10355aa5

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