From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- graphics/hpgl2ps/dxy2ps.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 graphics/hpgl2ps/dxy2ps.c (limited to 'graphics/hpgl2ps/dxy2ps.c') diff --git a/graphics/hpgl2ps/dxy2ps.c b/graphics/hpgl2ps/dxy2ps.c new file mode 100644 index 0000000000..89e20a6aa9 --- /dev/null +++ b/graphics/hpgl2ps/dxy2ps.c @@ -0,0 +1,90 @@ +#include "defn.h" + +#define USAGE "Usage: dxy2ps [-amr] [-l line sizes] [-s scale] [-x offset] [-y offset] [file]\n" + +main(argc, argv) +int argc; +char *argv[]; +{ + extern int optind; + extern char *optarg; + + char op; + int MANUAL_FEED = 0; /* DEFAULT: No manual feed */ + + PaperSize = "A3"; + Mode = "DXY"; + plotcoords(); /* Set up plotter coordinates */ + + plotinit(); /* Get other initialisations */ + + while ((ch = getopt(argc, argv, "al:ms:x:y:r")) != EOF) + { + switch (ch) + { + case 'a': /* DXY ISO A4 297mm * 210mm */ + PaperSize = "A4"; + plotcoords(); + break; + + case 'l': + changesizes(optarg); + break; + + case 'm': + MANUAL_FEED = 1; + break; + + case 'r': + LANDSCAPE = 0; + break; + + case 's': + SCALE = atof(optarg); + if (SCALE < 0.1) + SCALE = 0.1; + else + if (SCALE > 3) + SCALE = 3; + break; + + case 'x': + xoffset = atof(optarg); + break; + + case 'y': + yoffset = atof(optarg); + break; + + default: + fprintf(stderr, "%s\n", USAGE); + exit(1); + } + } + if (optind == argc) + stream = stdin; + else if ((stream = fopen(argv[optind], "r")) == NULL) + { + fprintf(stderr, "ERROR: cannot open \"%s\"\n", argv[optind]); + exit(1); + } + ps_macros(); /* Output PostScript Macros */ + + viewport(); /* Scale the viewport for the plot */ + + printf("/%s %g Font\n", font, char_height); + + if (MANUAL_FEED) + manualfeed(1); + + while ((op = getc(stream)) != EOF) + if ((isalpha(op) > 0) || op == '^') + dxycom(op); + + end_draw(); + + printf("showpage\n"); + + if (MANUAL_FEED) + manualfeed(0); +} -- cgit v1.2.3