xref: /original-bsd/lib/libplot/aed/space.c (revision 48cf0a37)
1 /*-
2  * Copyright (c) 1983, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.proprietary.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)space.c	8.1 (Berkeley) 06/04/93";
10 #endif /* not lint */
11 
12 #include "aed.h"
13 
14 /*---------------------------------------------------------
15  *	Space sets up the world-to-screen transformation so
16  *	that the rectangular area described by (x0, y0) and
17  *	(x1, y1) will all be on-screen.
18  *
19  *	Results:	None.
20  *
21  *	Side Effects:
22  *	Our own variables scale, xbot, and ybot are changed.
23  *---------------------------------------------------------
24  */
25 space(x0, y0, x1, y1)
26 int x0, y0, x1, y1;
27 {
28     int xscale, yscale, xsize, ysize;
29     xscale = (GRXMAX<<12)/(x1-x0);
30     yscale = (GRYMAX<<12)/(y1-y0);
31     if (xscale > yscale) scale = yscale;
32     else scale = xscale;
33     scale = (scale*9)/10 - 1;
34     if (scale<1) scale = 1;
35     xsize = (2048*GRXMAX)/scale + 1;
36     xbot = (x1+x0)/2 - xsize;
37     ysize = (2048*GRYMAX)/scale + 1;
38     ybot = (y1+y0)/2 - ysize;
39 }
40