From: Ben Harris Date: Tue, 25 Jul 2017 22:36:10 +0000 (+0100) Subject: Add mechanisms (as yet unused) for varying Bedstead's weight. X-Git-Tag: bedstead-002.000~121 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=78ccce6504a543401ceaa5df5143234830038f71;p=bedstead.git Add mechanisms (as yet unused) for varying Bedstead's weight. There are rather tight limits to the weights it can achieve, though. --- diff --git a/bedstead.c b/bedstead.c index 56ed868..8ba649e 100644 --- a/bedstead.c +++ b/bedstead.c @@ -1814,7 +1814,46 @@ emit_path() } if (started) printf("EndSplineSet\n"); } - + +/* + * To vary the weight of Bedstead, we just vary the thickness of + * vertical strokes. More precisely, we pretend that the weight + * variation is achieved by moving the rising edges of the output + * 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). + */ +static int weight = 0 * SCALE; + +static void +adjust_weight() +{ + int i; + point *p; + + for (i = 0; i < nextpoint; i++) { + p = &points[i]; + if (p->next == NULL) continue; + assert(p->prev != NULL); + /* Move left-edge points horizontally */ + if (p->prev->v.y <= p->v.y && p->v.y <= p->next->v.y) + p->v.x -= weight; + /* Move top inner corner points along NE/SW diagonal */ + if (p->prev->v.y < p->v.y && p->v.y > p->next->v.y && + p->prev->v.x > p->v.x && p->v.x > p->next->v.x) { + p->v.x -= weight/2; + p->v.y -= weight/2; + } + /* Move bottom inner corner points along NW/SE diagonal */ + if (p->prev->v.y > p->v.y && p->v.y < p->next->v.y && + p->prev->v.x < p->v.x && p->v.x < p->next->v.x) { + p->v.x -= weight/2; + p->v.y += weight/2; + } + } +} + static void blackpixel(int x, int y, int bl, int br, int tr, int tl) { @@ -1916,6 +1955,7 @@ dochar(char const data[YSIZE], unsigned flags) } } clean_path(); + adjust_weight(); emit_path(); }