1 Simple Graphics Package (SGP) Documentation
2 -------------------------------------------
5 Documentation and Software Written by Kevin Rosenberg
6 Copyright (c) 1984, Kevin Rosenberg
15 +------------------------+
16 | World Coordinate level |
17 +-----------+------------+
20 +------------+-------------+
21 | Convert to Normalized |
22 | device coordinates (NDC) |
23 +------------+-------------+
26 +------+-------+ +--------------+
27 | Segmentation +-----------+ Disk Storage |
28 +------+-------+ +--------------+
30 +------------+-------------+
31 | Convert to Physical |
32 | device coordinates (PDC) |
33 +--------------------------+
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
44 pntabs2 (x, y) Plot point at current position
46 lineabs2 (x, y) Draw line from current point to point
48 markabs2 (x, y) Draw marker at current position
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
57 calc_map () Calculate wc to ndc factors
58 clip(rectangle[4], x1, y1, x2, y2) Clip a line againt rectangle
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
77 setmarker (marker_type, color) Set marker attibutes
78 markndc (xndc, yndc) Draw marker at NDC position
80 ndc_to_pdc (device, xndc, yndc, xpdc, ypdc)
81 savescrn (filename, xmin, ymin, xmax, ymax)
87 crtline (x1, y1, x2, y2, color, style)
88 wrtchar (char, x, y, dotfunc())
89 wrttext (str, x, y, dotfunc())
91 readblock (array, xmin, ymin, xmax, ymax)
92 writeblock (array, xmin, ymin, mode)
95 prtline (func, x1, y1, x2, y2, color, style)
100 Physical device level
101 joystk (sticknum, x, y)
103 Normalized Coordinate level
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
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
130 float width, height; size of characters in NDC
131 int dirflag, orientflag text direction, character orientation
132 int fore, back; foreground & background color
142 Map directly from world coords to physical device coords
143 --------------------------------------------------------
145 Window: xwmin, xwmax, ywmin, ywmax
146 Viewport: xvmin, xvmax, yvmin, yvmax
147 Physical: xpmax, ypmax
149 To convert from wc to ndc:
150 xndc = xvmin + (xwc - xwmin) / (xwmax - xwmin)
151 yndc = yvmin + (ywc - ywmin) / (ywmax - ywmin)
153 To convert from ndc to pdc:
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))
161 xpdc = xpmax * xvmin + (xwc - xwmin) * (xpmax / (xwmax - xwmin))
162 = xadd + (xwc - xsub) * xfact
167 NORMAL Regular character set
168 BOLD Overstike chars with x offset by 1 pixel
169 ITALICS Shear characters along character height