r3: Initial revision
[ctsim.git] / man / sgp.1
1              Simple Graphics Package (SGP) Documentation
2              -------------------------------------------
3
4
5          Documentation and Software Written by Kevin Rosenberg
6                   Copyright (c) 1984, Kevin Rosenberg
7
8
9
10
11
12                             OVERVIEW
13                             --------
14
15                        +------------------------+
16                        | World Coordinate level |
17                        +-----------+------------+
18                                    |
19                                    |
20                       +------------+-------------+
21                       | Convert to Normalized    |
22                       | device coordinates (NDC) |
23                       +------------+-------------+
24                                    |
25                                    |
26                             +------+-------+           +--------------+
27                             | Segmentation +-----------+ Disk Storage |
28                             +------+-------+           +--------------+
29                                    |
30                       +------------+-------------+
31                       | Convert to Physical      |
32                       | device coordinates (PDC) |
33                       +--------------------------+
34
35
36 World Coordinate Level
37 ----------------------
38      initgrf2 ()                         Initialize 2 dimensional graphics
39      termgrf2 ()                         Terminate 2 dimensional graphics
40      window2  (xmin, ymin, xmax, ymax)   Set window for world coord
41      viewprt2 (xmin, ymin, xmax, ymax)   Viewport for window in NDC
42      moveabs2 (x, y)                     Move graphics cursor
43      moverel2 (dx, dy)
44      pntabs2 (x, y)                      Plot point at current position
45      pntrel2 (dx, dy)
46      lineabs2 (x, y)                     Draw line from current point to point
47      linerel2 (dx, dy)
48      markabs2 (x, y)                     Draw marker at current position
49      markrel2 (dx, dy)
50      polylnabs (x[], y[], n)             Draw a set of lines
51      polylnrel (dx[]. dy[]. n)
52      wc_to_ndc (xwc, ywc, xndc, yndc)    Convert from world coord to NDC
53      ndc_to_wc (xndc, yndc, xwc, ywc)    Convert from NDC to world coord
54      drawtext (str)                      Draw text string at current positon
55
56      INTERNAL:
57           calc_map ()                        Calculate wc to ndc factors
58           clip(rectangle[4], x1, y1, x2, y2) Clip a line againt rectangle
59
60
61 Normalized Coordinate level
62 --------------------------
63      stylus (x, y, beam)                 Draw a line from current position
64      opendevice (device)                 Open a device for output
65      closedevice (device)                Close a device for output
66      flushdevice (device)                Put all pending data on device
67      inqdev (device, xmax, ymax)         Return data on device
68      setcolor (color)                    Set current drawing color
69      setlinestyle (style)                Set current line style
70      setlinewidth (width)                Set current line width
71      settext (h, w, orientation, dir, font)  Set text attributes
72      settextclr (foreground, background) If back=-1, then transparent backg
73      inqtext(h, w, o, dir, font, fore, back) Get current text attributes
74      charndc (c, xndc, yndc)             Draw char at NDC position
75      textndc (str, xndc, yndc)           Draw text string at NDC position
76
77      setmarker (marker_type, color)      Set marker attibutes
78      markndc (xndc, yndc)                Draw marker at NDC position
79
80      ndc_to_pdc (device, xndc, yndc, xpdc, ypdc)
81      savescrn (filename, xmin, ymin, xmax, ymax)
82      readscrn (filename)
83
84 Physical Device Level
85 ---------------------
86      crtdot (x, y, c)
87      crtline (x1, y1, x2, y2, color, style)
88      wrtchar (char, x, y, dotfunc())
89      wrttext (str, x, y, dotfunc())
90
91      readblock (array, xmin, ymin, xmax, ymax)
92      writeblock (array, xmin, ymin, mode)
93
94      prtdot (x, y, c)
95      prtline (func, x1, y1, x2, y2, color, style)
96
97
98 Input Functions
99 ---------------
100 Physical device level
101      joystk (sticknum, x, y)
102
103 Normalized Coordinate level
104      readloc (xndc, yndc)
105      inithcur (height, width, color)         Initialize haircross cursor
106      movhcurabs (xndc, yndc)                 Move haircross cursor to point
107      movhcurrel (dxndc, dyndc)               Move relatively
108      termhcur ()                             Turn off haircross cursor
109      readpnt (xndc, yndc)                    Have cursor track joystick
110                                              User press button at desired point
111
112                                 DATA STRUCTURES
113                                 ---------------
114 struct DEVICE {
115      int xsize, ysize;                  Size of device in pixels
116      int xmax, ymax;                    Maximum coordinates
117      int colormax;                      Maximum color number of device
118      int style;                         Current linestyle of device
119      int width;                         Current width of device
120      int color;                         Current color of device
121      int curx, cury;                    Current position
122      int charwidth, charheight;         Size of characters in pixels
123      float aspt                         Aspect ratio  Multiple coord 
124      int (*dot)();                      Dot function for device
125      int (*line)();                     Line function for device
126      int mode;                          Device mode
127 };
128
129 struct CHARSPEC {
130      float width, height;               size of characters in NDC
131      int dirflag, orientflag            text direction, character orientation
132      int fore, back;                    foreground & background color
133 };
134
135 struct CURRENT {
136     int color;
137     int linestyle;
138     int linewidth;
139     float xndc, yndc;
140 }
141
142             Map directly from world coords to physical device coords
143             --------------------------------------------------------
144
145 Window:   xwmin, xwmax, ywmin, ywmax
146 Viewport: xvmin, xvmax, yvmin, yvmax
147 Physical: xpmax, ypmax
148
149 To convert from wc to ndc:
150      xndc = xvmin + (xwc - xwmin) / (xwmax - xwmin)
151      yndc = yvmin + (ywc - ywmin) / (ywmax - ywmin)
152
153 To convert from ndc to pdc:
154      xpdc = xndc * xpmax
155      ypdc = yndc * ypmax
156
157 So, for each device set up the following composite transformation:
158      xpdc = xpmax * (xvmin + (xwc - xwmin) / (xwmax - xwmin))
159      ypdc = ypmax * (yvmin + (ywc - ywmin) / (ywmax - ywmin))
160
161      xpdc = xpmax * xvmin + (xwc - xwmin) * (xpmax / (xwmax - xwmin))
162           = xadd + (xwc - xsub) * xfact
163
164 Characters
165 ----------
166      Fonts:
167           NORMAL              Regular character set
168           BOLD                Overstike chars with x offset by 1 pixel
169           ITALICS             Shear characters along character height
170
171                        NORMAL   BOLD    ITALICS
172                          X       XX         X
173                         XXX     XXXX      XXX
174                        X   X   XX  XX    X   X
175                        X   X   XX  XX    X   X
176                        XXXXX   XXXXXX   XXXXX
177                        X   X   XX  XX   X   X
178                        X   X   XX  XX   X   X
179
180
181
182
183