* New version of IRM New version of the IRM, updated to Medley. * moved to docs/medley-irm as discussed
301 lines
191 KiB
Plaintext
301 lines
191 KiB
Plaintext
INTERLISP-D REFERENCE MANUAL
|
||
GRAPHICS OUTPUT OPERATIONS
|
||
|
||
"27"26. GRAPHICS OUTPUT OPERATIONS
|
||
2
|
||
|
||
Streams are used as the basis for all I/O operations. Files are implemented as streams that can support character printing and reading operations, and file pointer manipulation. An image stream is a type of stream that also provides an interface for graphical operations. All of the operations that can applied to streams can be applied to image streams. For example, an image stream can be passed as the argument to PRINT, to print something on an image stream. In addition, special functions are provided to draw lines and curves and perform other graphical operations. Calling these functions on a stream that is not an image stream will generate an error.
|
||
Primitive Graphics Concepts
|
||
1
|
||
|
||
The Interlisp-D graphics system is based on manipulating bitmaps (rectangular arrays of pixels), positions, regions, and textures. These objects are used by all of the graphics functions.
|
||
Positions
|
||
A position denotes a point in an X,Y coordinate system. A POSITION is an instance of a record with fields XCOORD and YCOORD and is manipulated with the standard record package facilities. For example, (create POSITION XCOORD ¬ 10 YCOORD ¬ 20) creates a position representing the point (10,20).
|
||
(POSITIONP X) [Function]
|
||
Returns X if X is a position; NIL otherwise.
|
||
Regions
|
||
A Region denotes a rectangular area in a coordinate system. Regions are characterized by the coordinates of their bottom left corner and their width and height. A REGION is a record with fields LEFT, BOTTOM, WIDTH, and HEIGHT. It can be manipulated with the standard record package facilities. There are access functions for the REGION record that return the TOP and RIGHT of the region.
|
||
The following functions are provided for manipulating regions:
|
||
(CREATEREGION LEFT BOTTOM WIDTH HEIGHT) [Function]
|
||
Returns an instance of the REGION record which has LEFT, BOTTOM, WIDTH and HEIGHT as respectively its LEFT, BOTTOM, WIDTH, and HEIGHT fields.
|
||
Example: (CREATEREGION 10 -20 100 200) will create a region that denotes a rectangle whose width is 100, whose height is 200, and whose lower left corner is at the position (10,-20).
|
||
(REGIONP X) [Function]
|
||
Returns X if X is a region, NIL otherwise.
|
||
(INTERSECTREGIONS(INTERSECTREGIONS (Function) NIL NIL ("27") 2) REGION1 REGION2 ... REGIONn) [NoSpread Function]
|
||
Returns a region which is the intersection of a number of regions. Returns NIL if the intersection is empty.
|
||
(UNIONREGIONS(UNIONREGIONS (Function) NIL NIL ("27") 2) REGION1 REGION2 ... REGIONn) [NoSpread Function]
|
||
Returns a region which is the union of a number of regions, i.e. the smallest region that contains all of them. Returns NIL if there are no regions given.
|
||
(REGIONSINTERSECTP(REGIONSINTERSECTP (Function) NIL NIL ("27") 2) REGION1 REGION2) [Function]
|
||
Returns T if REGION1 intersects REGION2. Returns NIL if they do not intersect.
|
||
(SUBREGIONP(SUBREGIONP (Function) NIL NIL ("27") 2) LARGEREGION SMALLREGION) [Function]
|
||
Returns T if SMALLREGION is a subregion (is equal to or entirely contained in) LARGEREGION; otherwise returns NIL.
|
||
(EXTENDREGION(EXTENDREGION (Function) NIL NIL ("27") 2) REGION INCLUDEREGION) [Function]
|
||
Changes (destructively modifies) the region REGION so that it includes the region INCLUDEREGION. It returns REGION.
|
||
(MAKEWITHINREGION(MAKEWITHINREGION (Function) NIL NIL ("27") 2) REGION LIMITREGION) [Function]
|
||
Changes (destructively modifies) the left and bottom of the region REGION so that it is within the region LIMITREGION, if possible. If the dimension of REGION are larger than LIMITREGION, REGION is moved to the lower left of LIMITREGION. If LIMITREGION is NIL, the value of the variable WHOLEDISPLAY (the screen region) is used. MAKEWITHINREGION returns the modified REGION.
|
||
(INSIDEP(INSIDEP (Function) NIL NIL ("27") 2) REGION POSORX Y) [Function]
|
||
If POSORX and Y are numbers, it returns T if the point (POSORX,Y) is inside of REGION. If POSORX is a POSITION, it returns T if POSORX is inside of REGION. If REGION is a WINDOW, the window's interior region in window coordinates is used. Otherwise, it returns NIL.
|
||
Bitmaps
|
||
The display primitives manipulate graphical images in the form of bitmaps. A bitmap is a rectangular array of "pixels," each of which is an integer representing the color of one point in the bitmap image. A bitmap is created with a specific number of bits allocated for each pixel. Most bitmaps used for the display screen use one bit per pixel, so that at most two colors can be represented. If a pixel is 0, the corresponding location on the image is white. If a pixel is 1, its location is black. This interpretation can be changed for the display screen with the function VIDEOCOLOR. Bitmaps with more than one bit per pixel are used to represent color or grey scale images. Bitmaps use a positive integer coordinate system with the lower left corner pixel at coordinate (0,0). Bitmaps are represented as instances of the datatype BITMAP. Bitmaps can be saved on files with the VARS file package command.
|
||
(BITMAPCREATE WIDTH HEIGHT BITSPERPIXEL) [Function]
|
||
Creates and returns a new bitmap which is WIDTH pixels wide by HEIGHT pixels high, with BITSPERPIXEL bits per pixel. If BITSPERPIXEL is NIL, it defaults to 1.
|
||
(BITMAPP(BITMAPP (Function) NIL NIL ("27") 3) X) [Function]
|
||
Returns X if X is a bitmap, NIL otherwise.
|
||
(BITMAPWIDTH(BITMAPWIDTH (Function) NIL NIL ("27") 3) BITMAP) [Function]
|
||
Returns the width of BITMAP in pixels.
|
||
(BITMAPHEIGHT(BITMAPHEIGHT (Function) NIL NIL ("27") 3) BITMAP) [Function]
|
||
Returns the height of BITMAP in pixels.
|
||
(BITSPERPIXEL BITMAP) [Function]
|
||
Returns the number of bits per pixel of BITMAP.
|
||
(BITMAPBIT(BITMAPBIT (Function) NIL NIL ("27") 3) BITMAP X Y NEWVALUE) [Function]
|
||
If NEWVALUE is between 0 and the maximum value for a pixel in BITMAP, the pixel (X,Y) is changed to NEWVALUE and the old value is returned. If NEWVALUE is NIL, BITMAP is not changed but the value of the pixel is returned. If NEWVALUE is anything else, an error is generated. If (X,Y) is outside the limits of BITMAP, 0 is returned and no pixels are changed. BITMAP can also be a window or display stream. Note: non-window image streams are "write-only"; the NEWVALUE argument must be non-NIL.
|
||
(BITMAPCOPY(BITMAPCOPY (Function) NIL NIL ("27") 3) BITMAP) [Function]
|
||
Returns a new bitmap which is a copy of BITMAP (same dimensions, bits per pixel, and contents).
|
||
(EXPANDBITMAP(EXPANDBITMAP (Function) NIL NIL ("27") 3) BITMAP WIDTHFACTOR HEIGHTFACTOR) [Function]
|
||
Returns a new bitmap that is WIDTHFACTOR times as wide as BITMAP a
|
||
nd HEIGHTFACTOR times as high. Each pixel of BITMAP is copied into a WIDTHFACTOR times HEIGHTFACTOR block of pixels. If NIL, WIDTHFACTOR defaults to 4, HEIGHTFACTOR to 1.
|
||
(ROTATEBITMAP(EXPANDBITMAP (Function) NIL NIL ("27") 4) BITMAP) [Function]
|
||
Given an m-high by n-wide bitmap, this function returns an n-high by m-wide bitmap. The returned bitmap is the image of the original bitmap, rotated 90 degrees clockwise.
|
||
(SHRINKBITMAP(SHRINKBITMAP (Function) NIL NIL ("27") 4) BITMAP WIDTHFACTOR HEIGHTFACTOR DESTINATIONBITMAP) [Function]
|
||
Returns a copy of BITMAP that has been shrunken by WIDTHFACTOR and HEIGHTFACTOR in the width and height, respectively. If NIL, WIDTHFACTOR defaults to 4, HEIGHTFACTOR to 1. If DESTINATIONBITMAP is not provided, a bitmap that is 1/WIDTHFACTOR by 1/HEIGHTFACTOR the size of BITMAP is created and returned. WIDTHFACTOR and HEIGHTFACTOR must be positive integers.
|
||
(PRINTBITMAP(PRINTBITMAP (Function) NIL NIL ("27") 4) BITMAP FILE) [Function]
|
||
Prints the bitmap BITMAP on the file FILE in a format that can be read back in by READBITMAP.
|
||
(READBITMAP(READBITMAP (Function) NIL NIL ("27") 4) FILE) [Function]
|
||
Creates a bitmap by reading an expression (written by PRINTBITMAP) from the file FILE.
|
||
(EDITBM(EDITBM (Function) NIL NIL ("27") 4) BMSPEC) [Function]
|
||
EDITBM provides an easy-to-use interactive editing facility for various types of bitmaps. If BMSPEC is a bitmap, it is edited. If BMSPEC is an atom whose value is a bitmap, its value is edited. If BMSPEC is NIL, EDITBM asks for dimensions and creates a bitmap. If BMSPEC is a region, that portion of the screen bitmap is used. If BMSPEC is a window, it is brought to the top and its contents edited.
|
||
EDITBM sets up the bitmap being edited in an editing window. The editing window has two major areas: a gridded edit area in the lower part of the window and a display area in the upper left part. In the edit area, the left button will add points, the middle button will erase points. The right button provides access to the normal window commands to reposition and reshape the window. The actual size bitmap is shown in the display area. For example, the following is a picture of the bitmap editing window editing a eight-high by eighteen-wide bitmap:
|
||
|