Coordinate systems

Most graphic primitives have to place objects, on the screen for instance, given some coordinates; we call a ``point'' the information necessary to explicit a location on the output device.

By default, a point is a pair of whole numbers, the X and Y coordinates, and therefore it is highly device-dependent: using a Color Graphic Adapter (CGA) mode, for instance, the valid coordinate range is {\itt '(0 .\ 0)} through {\itt '(319 .\ 199)} in 4-color mode, and {\itt '(0 .\ 0)} and {\itt '(639 .\ 199)} in Black&White mode. With a Hercules-monochrome adapter, the range becomes {\itt '(0 .\ 0)} through {\itt '(719 .\ 347)}, and so on; {\itt '(0 .\ 0)} is always the upper left corner of the screen, contrary to mathematical tradition. Note that BGI routines usually clip their parameters to the screen rectangle.

Now PCSCHEME allows you to freely define the coordinate system you'd like to use. You only need to specify the desired coordinates of the upper left and bottom right corner, no matter which video adapter or other device is present. A typical sequence would be:



(set-world! {\itt '(-100 .\ -100)} {\itt '(100 .\ 100)}) 
(init-graph) 		 ; detect and initialize video adapter 

(set-world! {\itt '(-100 .\ -100)} {\itt '(100 .\ 100)}) ; set the screen coordinates with origin centered
(put-pixel {\itt '(0 .\ 0)} {\itt 'BLUE}) ; plot a blue pixel at center of screen

Note that the X and Y coordinates are now real numbers, so you are allowed to call SET-WORLD! with parameters like:



(set-world! `((- ,pi) . 1) `(,pi . -1)) ; ideal to plot a sine...

Of course, if you need to scan every pixel, you can use GET-MAX-XY to obtain the actual resolution of your screen adapter.

If you are urging to try BGI by yourself, skip to part [*], page [*]. What follows is an extension to the BGI standard.