From: Ben Harris Date: Tue, 1 Aug 2017 17:11:51 +0000 (+0100) Subject: Shuffle scaling around so we always work on 100×100 pixels. X-Git-Tag: bedstead-002.000~102 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=7a06191a8fda45d147dde6a103fd0110c930296d;p=bedstead.git Shuffle scaling around so we always work on 100×100 pixels. Width variations are not catered for by scaling on output. --- diff --git a/bedstead.c b/bedstead.c index e0ff03e..f251230 100644 --- a/bedstead.c +++ b/bedstead.c @@ -175,14 +175,16 @@ static int const nwidths = sizeof(widths) / sizeof(widths[0]); struct width const *width = &widths[0]; -/* Size of pixels in font design units (usually 1000/em) */ +/* Size of output pixels in font design units (usually 1000/em) */ #define XPIX (width->xpix) #define YPIX 100 -/* We work internally in smaller units, though. */ -#define SCALE 2 -#define XPIX_S (XPIX * SCALE) -#define YPIX_S (YPIX * SCALE) +/* Internally, we work in pixels 100 design units square */ +#define XPIX_S 100 +#define YPIX_S 100 + +#define XSCALE ((double)XPIX_S / (double)XPIX) +#define YSCALE ((double)YPIX_S / (double)YPIX) /* Position of diagonal lines within pixels */ #define XQTR_S (XPIX_S/4) @@ -1831,8 +1833,8 @@ emit_path() started = 1; do { printf(" %g %g %s 1\n", - (double)p->v.x / SCALE, - (double)p->v.y / SCALE - 3*YPIX, + (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; @@ -1850,9 +1852,9 @@ emit_path() * waveform of the SAA5050. This is implemented by moving all left * edges left and right. The code below only handles cases where we * don't run out of slack in horizontal lines, which limits weight to - * the range (-50 * SCALE) < weight < (25 * SCALE). + * the range (-0.5 * XPIX) < weight < (0.25 * XPIX). */ -static int weight = 0 * SCALE; +static int weight = 0; static void adjust_weight()