summaryrefslogtreecommitdiff
path: root/graphics/hpgl2ps/viewport.c
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /graphics/hpgl2ps/viewport.c
Initial commit
Diffstat (limited to 'graphics/hpgl2ps/viewport.c')
-rw-r--r--graphics/hpgl2ps/viewport.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/graphics/hpgl2ps/viewport.c b/graphics/hpgl2ps/viewport.c
new file mode 100644
index 0000000000..ac34586842
--- /dev/null
+++ b/graphics/hpgl2ps/viewport.c
@@ -0,0 +1,38 @@
+/*
+ * This procedure sets up the variables for the translation of plotter
+ * coordinates to PostScript coordinates.
+ *
+ * Note: the procedure "defaults" may be incorporated here, however
+ * I have not had the time to work it out properly.
+ *
+ * Don McCormick
+ */
+#include "defn.h"
+
+viewport()
+{
+ float pagewidth = 197.0; /* Page width for Laser Printer */
+ float pageheight = 280.0; /* Page height for Laser Printer */
+ float pwoffset = 12;
+ float phoffset = 12;
+
+ float psxmax, psymax; /* Sizes scaled to the viewport */
+
+ if (LANDSCAPE) /* Default mode */
+ {
+ psymax = pagewidth * 0.938095;
+ psxmax = psymax * (xmax - xmin)/ (ymax - ymin);
+ xoffset += (pageheight + phoffset - psxmax) / 2.0;
+ yoffset -= (pagewidth + pwoffset + psymax) / 2.0;
+ printf("90 rotate\n");
+ } else
+ {
+ psxmax = pagewidth * 0.938095;
+ psymax = psxmax * (ymax - ymin) / (xmax - xmin);
+ xoffset += (pagewidth + pwoffset - psxmax) / 2.0;
+ yoffset += (pageheight + phoffset - psymax) / 2.0;
+ }
+ printf("%g mm %g mm translate\n", xoffset, yoffset);
+ XSCALE = psxmax / xmax * SCALE;
+ YSCALE = psymax / ymax * SCALE;
+}