summaryrefslogtreecommitdiff
path: root/graphics/hpgl2ps/viewport.c
blob: ac345868425b22d42fa5288560d5eb9ab1afe53c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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;
}