chiark / gitweb /
Shuffle scaling around so we always work on 100×100 pixels.
authorBen Harris <bjh21@bjh21.me.uk>
Tue, 1 Aug 2017 17:11:51 +0000 (18:11 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Tue, 1 Aug 2017 17:11:51 +0000 (18:11 +0100)
Width variations are not catered for by scaling on output.

bedstead.c

index e0ff03e04c79d91e52fb0d73bfbf32dfcdfc1607..f25123096050204f357c645a76013668007b8abc 100644 (file)
@@ -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()