/* Last edited on 2024-12-31 14:49:34 by stolfi */ /* hxg_ps.c */ epswr_figure_t *hxg_ps_init_plot ( interval_t B[], char *name, bool_t @e@p@s@, char *paperSize ); /* Creates a Postscript figure stream, and sets up the scales and windows for plotting things in the ranges {B[0],B[1]}. Use the commands in {epswr.h} or {hxg_ps.h} for plotting. Be sure to call {epswr_end_figure} before exiting the program. If {@e@p@s@=TRUE} the stream will be a set of Encapsulated Postscript figures, about 5 inches wide, called "{name}-{NNNNNN}.@e@p@s@", for integers {NNNNNN} starting from 0; the {paperSize} is ignored. Otherwise the stream will be a standalone Postscript document with the given {paperSize} ("a4", "a3", etc.) called "{name}.eps". */ epswr_figure_t *hxg_ps_init_plot ( interval_t B[], char *name, bool_t @e@p@s@, char *paperSize ) { /* Compute the plotting ranges with some slop: */ double zxraw = HI(B[0]) - LO(B[0]), zyraw = HI(B[1]) - LO(B[1]); /* Extents. */ double mx = 0.05 * zxraw, my = 0.05 * zyraw; /* Margins */ double xmin = LO(B[0]) - mx, xmax = HI(B[0]) + mx, zx = xmax - xmin; double ymin = LO(B[1]) - my, ymax = HI(B[1]) + my, zy = ymax - ymin; /* Choose/get nominal page/figure size and margins: */ double hPaper, vPaper; double hMargin, vMargin; if (@e@p@s@) { /* Set figure width to 6 inches, height in proportion, plus 4pt margin: */ hMargin = 4.0; vMargin = 4.0; hPaper = 6.0*72.0 + 2*hMargin; vPaper = hPaper * zy/zx + 2*vMargin; } else { /* Set figure width and height to paper size, and margins to 1 inch: */ epswr_get_paper_dimensions(paperSize, FALSE, &hPaper, &vPaper); hMargin = 72.0; vMargin = 72.0; } /* Create a new Postscript document, with canvas size larger : */ epswr_figure_t *eps = epswr_new_named_figure(name, NULL, @e@p@s@, "doc", paperSize, FALSE, hPaper, vPaper); /* Set one picture per page, with the right format: */ int32_t capLines = (@e@p@s@ ? 0 : 4); epswr_set_canvas_layout(eps, zx, zy, TRUE, hMargin, vMargin, capLines, 1,1); /* First picture: */ epswr_set_client_window (eps, xmin, xmax, ymin, ymax); return eps; }