10 The graphics Library

The graphics library is defining a simple drawing system (without any event handling facilities). Graphics is intended for lightweight drawings in canvasses, dialogs, etc., where user interaction with the drawings are not important.

Graphics defines a pen for controlling the color, size, etc. of the lines and points to be drawn. Furthermore, graphics defines seleval drawing operations, such as moveTo, drawTo, drawSpot, drawLine, etc.

10.1 Using the graphics Library

Remember that in order to utilize this extension to Lidskjalv, the fragment graphics must be included as follows:

ORIGIN '~beta/guienv/guienv';
INCLUDE '~beta/guienv/graphics'
--- program: descriptor ---
guienv(# pm: @pixmap;
         ...
      do ...
         ... -> pm.read;
         ...
      #)

10.2 Examples of Use of the graphics Fragment

This example illustrates reading a pixmap from a file and display it on the screen.

Program 9: drawbitmap.bet

ORIGIN '~beta/guienv/guienv';
INCLUDE '~beta/guienv/graphics';
(* This demo is an example showing how read a bitmap from a file, and
 * using the graphics pattern to draw the bitmap on the screen.
 *)
--- program: descriptor ---
guienv
(# pm: @pixmap;
   theWindow: @window
     (# eventhandler::
          (# onAboutToClose:: (# do terminate #) #);
        obj: @windowItem
          (# open::
               (# 
               do (50,50) -> position;
                  (pm.width,pm.height) -> size
               #);
             eventHandler::
               (# onRefresh::
                    (# 
                    do graphics
                       (# 
                       do (pm[], (0, 0), (0, 0), pm.width,pm.height)
                            -> drawRaster
                       #)
                    #);
                  onMouseDown::
                    (# do drag #)
               #)
          #);
        open::
          (# 
          do (400,400) -> size;
             obj.open
          #)
     #)
do 'picture' -> pm.read;
   (0xffff,0xffff,0xffff)->pm.transparentcolor;
   theWindow.open
#)
[9kb 405x85 GIF]


Lidskjalv: User Interface Framework - Reference Manual
© 1994-2004 Mjølner Informatics
[Modified: Friday October 27th 2000 at 14:56]