gp is a simple, device independent, two-dimensional vector graphics package. It is mainly a tool for research in portable graphics, but has been used for ``serious'' work.
The package is implemented in two layers:
The layer gp is device independent and merely takes care of mapping user coordinates to device coordinates before calling dv primitives, which do the actual drawing.
The layer dv implements the drawing metaphor defined in gp for a particular device. A layer dv must be written for each device.
The philosophy is that the devices are ``intelligent'', in the sense that they ``know'' how to perform the required drawings. In most cases, the device is actually another graphics package. The main function of dv is to map the gp drawing metaphor onto the native drawing metaphor of the device, thus proving a common API for using different devices.
The functions available in gp can be divided into the following categories:
void gpbegin(int c)
- begin poly primitive with code c.
void gpbox(real xmin, real xmax, real ymin, real ymax)
- draw solid rectangular box with diagonal (xmin, ymin)-(xmax, ymax).
void gpclear(int wait)
- clear device, possibily waiting for user input before acting.
void gpclose(int wait)
- close graphics package, possibily waiting for user input before acting.
int gpcolor(int c)
- select color number c as the current drawing color.
- end last open poly primitive.
char* gpevent(int wait, real* x, real* y)
- get next event in queue.
- flush graphics buffer.
int gpfont(char* name)
- select font name as the current text font.
void gpline(real x1, real y1, real x2, real y2)
- draw line segment from (x1,y1) to (x2,y2) .
- compute viewing transformation.
void gpmark(int size, char* mark)
- set size and type of marker.
real gpopen(char* title)
- open graphics package.
int gppalette(int c, char* name)
- bind color name to color number c .
void gpplot(real x, real y)
- plot a marker at (x,y) .
int gppoint(real x, real y)
- add point (x,y) to current poly primitive.
int gprgb(int c, real r, real g, real b)
- bind rgb color (r,g,b) to color number c .
void gptext(real x, real y, char* s, char* mode)
- draw text s at (x,y) with alignment defined by mode .
void gptri(real x1, real y1, real x2, real y2, real x3, real y3)
- draw solid triangle with vertices (x1,y1), (x2,y2), (x3,y3) .
void gpunview(real* x, real* y)
- perform inverse viewing transformation on device point (x,y) .
void gpview(real* x, real* y)
- perform viewing transformation on user point (x,y) .
real gpviewport(real xmin, real xmax, real ymin, real ymax)
- define viewport in normalized device coordinates.
void gpwait(int t)
- sleep t miliseconds or wait for user input.
real gpwindow(real xmin, real xmax, real ymin, real ymax)
- define window in user coordinates.
dv, CORE, GKS, SRGP, and several others.
gp is yet another graphics package.
Several gp functions are actually #define 'd as the corresponding dv functions.
J. R. Rankin, Computer Graphics Software Construction, Prentice Hall, 1989.
W. M. Newman and R. F. Sproull, Principles of Interactive Computer Graphics, McGraw--Hill, 1979.
J. D. Foley, A. van Dam, S. K. Freiner and J. F. Hughes, Computer Graphics: Principles and Practice, Addison--Wesley, 1990.
Please send your comments, bug reports, suggestions, etc ... to
Luiz Henrique de Figueiredo (firstname.lastname@example.org)