From 7a06191a8fda45d147dde6a103fd0110c930296d Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Tue, 1 Aug 2017 18:11:51 +0100 Subject: [PATCH] =?utf8?q?Shuffle=20scaling=20around=20so=20we=20always=20?= =?utf8?q?work=20on=20100=C3=97100=20pixels.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Width variations are not catered for by scaling on output. --- bedstead.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) 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() -- 2.30.2