1 Graphics VAX BASIC has two-dimensional graphics capabilities based on VAX GKS. This functionality is optional and is only available when VAX GKS is installed on your system. 2 ACTIVATE_DEVICE The ACTIVATE DEVICE statement allows you to activate an output device that has been explicitly deactivated. Subsequent graphics output is displayed on the specified device. VAX BASIC automatically activates a device when it is opened with an OPEN...FOR GRAPHICS statement. Example EXTERNAL PICTURE square,circle OPEN "VTA247" FOR GRAPHICS AS DEVICE #2 OPEN "RT1" FOR GRAPHICS AS DEVICE #3 . . . DEACTIVATE DEVICE #2 DRAW square !Output goes only to dev #3 CLEAR #2 ACTIVATE DEVICE #2 DRAW circle !Output goes to dev #2 and #3 3 Syntax ACTIVATE DEVICE #dev-id 2 ASK_Statements Certain ASK statements provide information on the size and type of your device, the boundaries of the device window and the device viewport, as well as the device's maximum color index. Other ASK statements let you determine the current value of attributes. Attributes for graphics text include the character height, the character font and the text path; attributes for lines and points include size, style and color. Each attribute has an initial default value which you can change using the appropriate SET statement. 3 AREA_STYLE The ASK AREA STYLE statement retrieves the value for the current area style. The area style can be one of four possible values: HOLLOW, SOLID, PATTERN or HATCH. The initial area style is solid. Example OPTION TYPE = EXPLICIT EXTERNAL PICTURE strip DECLARE STRING which_style ASK AREA STYLE which_style DRAW strip IF which_style = "SOLID" THEN SET AREA STYLE "HOLLOW" END IF DRAW strip WITH SHIFT(0.4,0) END 4 Syntax ASK AREA STYLE str-var 3 AREA_STYLE_INDEX The ASK AREA STYLE INDEX statement retrieves the value for the current style index. The index is a pointer into the various hatch or pattern styles. There is no index value for solid or hollow areas. See the manual Programming with VAX BASIC Graphics for sample index styles. Example DECLARE LONG which_ind ASK AREA STYLE INDEX which_ind IF which_ind > 32% THEN SET AREA STYLE INDEX (which_ind - 32%) END IF 4 Syntax ASK AREA STYLE INDEX int-var 3 CLIP The ASK CLIP statement allows you to determine whether clipping is currently on or off. At the start of program execution, clipping is on. For more information on clipping, see the manual Programming with VAX BASIC Graphics. Example DECLARE STRING clipping SET WINDOW , TRAN 2 : 0,1,0,0.5 ASK CLIP clipping 4 Syntax ASK CLIP str-var 3 ...COLOR The ASK...COLOR statements allow you to retrieve the current color index used to display the specified graphics object. The default index is 1. Example OPTION TYPE = EXPLICIT DECLARE LONG color_var ASK TEXT COLOR color_var GRAPH TEXT AT 0.2,0.6 :"This shows which color = " + STR$(color_var) END 4 Syntax ASK {POINT} COLOR int-var {LINE } {AREA } {TEXT } 3 COLOR_MIX The ASK COLOR MIX statement retrieves the current values for the intensities of red, green, and blue associated with the specified color index. Example DECLARE SINGLE red, green, blue !Ask for the 3 default intensities associated with INDEX 2 ASK COLOR MIX, INDEX 2 : red, green, blue 4 Syntax ASK COLOR MIX [#dev-id] ,INDEX int-exp : real-var1, real-var2, real-var3 3 DEVICE_SIZE The ASK DEVICE SIZE statement lets you determine the actual size of the available display surface on a particular device. Example OPEN "VT101" FOR GRAPHICS AS DEVICE #1 DECLARE STRING measure DECLARE SINGLE x_coord,y_coord ASK DEVICE SIZE #1 : x_coord, y_coord, measure 4 Syntax ASK DEVICE SIZE [#dev-id : ] real-var1, real-var2, [ str-var ] 3 DEVICE_TYPE The ASK DEVICE TYPE statement retrieves the device type of the specified device. Example OPTION TYPE = EXPLICIT DECLARE LONG what_type !Ask for type of device opened ASK DEVICE TYPE what_type IF what_type = 41 THEN CALL wkstation_proc END IF 4 Syntax ASK DEVICE TYPE [#dev-id : ] int-var 3 DEVICE_VIEWPORT The ASK DEVICE VIEWPORT statement retrieves the current values for the boundaries of the device viewport rectangle. Example OPTION TYPE = EXPLICIT OPEN "VT247" FOR GRAPHICS AS DEVICE #1 DECLARE SINGLE left_1,right_1,bottom,top SET WINDOW 0,100,0,100 ASK DEVICE VIEWPORT #1 : left_1, right_1, bottom, top 4 Syntax ASK DEVICE VIEWPORT [#dev-id : ] var-list Var-list must be four floating-point variables for the left, right, bottom, and top boundaries. 3 DEVICE_WINDOW The ASK DEVICE WINDOW statement allows you to retrieve the current values of the boundaries for the device window. Example OPTION TYPE = EXPLICIT DECLARE SINGLE left_1,right_1,bottom,top SET WINDOW 0,100,0,100 ASK DEVICE WINDOW left_1, right_1, bottom,top 4 Syntax ASK DEVICE WINDOW [#dev-id : ] var-list Var-list must be four floating-point variables for the left, right, bottom, and top boundaries. 3 ...ECHO_AREA The ASK...ECHO statements allow you to retrieve the values of the current boundaries of the echo area for a particular input type. The boundaries are assigned in device coordinates. Example OPTION TYPE = EXPLICIT DECLARE SINGLE xmin,xmax,ymin,ymax, & STRING what LOCATE STRING what ASK STRING ECHO AREA xmin, xmax, ymin, ymax 4 Syntax ASK {CHOICE} ECHO AREA [[#dev-id ] {:}] var-list {STRING} [,UNIT int-exp ] {VALUE } Var-list must be four floating-point variables for the left, right, bottom, and top boundaries. 3 MAX_COLOR The ASK MAX COLOR statement retrieves the maximum color index value for the specified device. Example OPTION TYPE = EXPLICIT DECLARE LONG highest_color OPEN "my_term" FOR GRAPHICS AS DEVICE #1 ASK MAX COLOR #1 : highest_color 4 Syntax ASK MAX COLOR [#dev-id : ] num-var 3 MAX_LINE_SIZE The ASK MAX LINE SIZE statement retrieves the maximum scale factor for the width of lines. Example OPTION TYPE = EXPLICIT DECLARE LONG fattest OPEN "VT109" FOR GRAPHICS AS DEVICE #1, TYPE 13 ASK MAX LINE SIZE : #1: fattest 4 Syntax ASK MAX LINE SIZE [#dev-id : ] num-var 3 MAX_POINT_SIZE The ASK MAX POINT SIZE statement retrieves the maximum scale factor for POINT output. Example DECLARE LONG largest OPEN "my_term" FOR GRAPHICS AS DEVICE #1, TYPE 13 ASK MAX POINT SIZE #1 : largest SET POINT SIZE largest GRAPH POINTS 0.5,0.5 4 Syntax ASK MAX POINT SIZE [#dev-id : ] num-var 3 ...STYLE The ASK...STYLE statements allow you to determine the current style of points or lines. Example DECLARE LONG whats_the_point !Store the current point style ASK POINT STYLE whats_the_point 4 Syntax ASK {POINT} STYLE int-var {LINE } 3 TEXT_ANGLE The ASK TEXT ANGLE statement allows you to retrieve the current angle of text rotation. Example OPTION TYPE = EXPLICIT OPTION ANGLE = DEGREES DECLARE SINGLE turn ASK TEXT ANGLE turn SET TEXT ANGLE (turn + 45) 4 Syntax ASK TEXT ANGLE real-var 3 TEXT_EXPAND The ASK TEXT EXPAND statement allows you to retrieve the current ratio of character width to height. Example DECLARE SINGLE how_fat !+ !Store current setting !- ASK TEXT EXPAND how_fat SET TEXT EXPAND 2 GRAPH TEXT AT 0.0,0.9 : "This might be hard to read" SET TEXT EXPAND how_fat 4 Syntax ASK TEXT EXPAND real-var 3 TEXT_EXTENT The ASK TEXT EXTENT statement allows you to retrieve values for the boundaries of the text extent rectangle for a given text string. Example OPTION TYPE = EXPLICIT DIM SINGLE x_coords(3), y_coords(3) SET WINDOW 0,100,0,100 SET TEXT HEIGHT 4 ASK TEXT EXTENT , "A perfect fit." AT 10,50 & : X_coords, Y_coords 4 Syntax ASK TEXT EXTENT [ #dev-id ] ,str-exp AT x-coord, y-coord : x-array, y-array 3 TEXT_FONT The ASK TEXT FONT statement retrieves the number of the font and optionally the value of the text precision. Possible values for the level of text precision are in increasing order: "STRING", "CHAR", or "STROKE". Example DECLARE LONG this_font, & STRING precision ASK TEXT FONT this_font, precision 4 Syntax ASK TEXT FONT int-var [, str-var] 3 TEXT_HEIGHT The ASK TEXT HEIGHT statement retrieves the current value of the text height in world coordinates. Example OPTION TYPE = EXPLICIT DECLARE SINGLE current_height !+ !Ask for height in default scale !- ASK TEXT HEIGHT current_height 4 Syntax ASK TEXT HEIGHT real-var 3 TEXT_JUSTIFY The ASK TEXT JUSTIFY statement retrieves the current values of the horizontal and vertical components of text justification. Example DECLARE STRING horiz_justify, vert_justify . . . ASK TEXT JUSTIFY horiz_justify, vert_justify IF horiz_justify = "NORMAL" AND vert_justify = "NORMAL" THEN SET TEXT JUSTIFY "LEFT", "BOTTOM" END IF 4 Syntax ASK TEXT JUSTIFY str-var1, str-var2 3 TEXT_PATH The ASK TEXT PATH statement retrieves the current value for the direction of the text path. Example OPTION TYPE = EXPLICIT DECLARE STRING CONSTANT my_way = "LEFT" DECLARE STRING which_way . . . ASK TEXT PATH which_way IF which_way = "RIGHT" THEN SET TEXT PATH my_way END IF 4 Syntax ASK TEXT PATH str-var 3 TEXT_POINT The ASK TEXT POINT statement allows you to retrieve the coordinates for the concatenation point of a text string. Example OPTION TYPE = EXPLICIT DIM SINGLE x_coords(3), y_coords(3) DECLARE SINGLE concat_x, concat_y SET WINDOW 0,100,0,100 SET TEXT HEIGHT 4 ASK TEXT EXTENT , "A perfect fit." AT 10,50 & : x_coords , y_coords ASK TEXT POINT , "A perfect fit." AT 10,50 & : concat_x, concat_y 4 Syntax ASK TEXT POINT [#dev-id ] ,str-exp AT x-coord1, y-coord1 : x-coord2, y-coord2 3 TEXT_SPACE The ASK TEXT SPACE statement retrieves the value for the current spacing between characters. Example DECLARE SINGLE spaced_out ASK TEXT SPACE spaced_out 4 Syntax ASK TEXT SPACE real-var 3 TRANSFORMATION The ASK TRANSFORMATION statement lets you determine which transformation is currently being used to map world coordinate points onto the world viewport in NDC space. This is the current transformation for both input and output. Transformation 1 is the default. Example DECLARE LONG which_tran . . . ASK TRANSFORMATION which_tran IF which_tran = 1 THEN SET TRANSFORMATION 2 ELSE GOTO Set_up_screens END IF 4 Syntax ASK TRANSFORMATION int-var 3 TRANSFORMATION_LIST The ASK TRANSFORMATION LIST statement retrieves the list of defined transformation numbers, starting with the most recently established transformation. The most recently established transformation is the transformation with the highest priority for input. Example DIM LONG xforms(15) DECLARE LONG how_many . . . ASK TRANSFORMATION LIST , COUNT how_many : xforms 4 Syntax ASK TRANSFORMATION LIST [ , COUNT int-var : ] int-array 3 VIEWPORT The ASK VIEWPORT statement retrieves the current values for the boundaries of the world viewport. When no transformation is specified, the boundaries for the default viewport are retrieved. Example DECLARE SINGLE left_1,right_1,bottom,top . . . ASK VIEWPORT ,TRAN 2 : left_1,right_1,bottom,top 4 Syntax ASK VIEWPORT [ , TRAN int-var : ] var-list Var-list must be four floating-point variables for the left, right, bottom, and top boundaries. 3 WINDOW The ASK WINDOW statement retrieves the current values for the boundaries of the world window. When no transformation is specified, the boundaries for the default window are retrieved. Example OPTION TYPE = EXPLICIT EXTERNAL PICTURE sine_curve,fudge_it DECLARE SINGLE left_1,right_1,bottom,top . . . ASK WINDOW, TRAN 2 : left_1, right_1, bottom, top IF bottom <= -1 AND top >= 1 THEN DRAW sine_curve ELSE DRAW fudge_it END IF 4 Syntax ASK WINDOW [ , TRAN int-var : ] var-list Var-list must be four floating-point variables for the left, right, bottom, and top boundaries. 2 CLEAR The CLEAR statement clears graphics text and images from the screen if the screen is not already clear. If no device is specified, VAX BASIC clears the default device. Example OPEN term_name FOR GRAPHICS AS DEVICE #1 OPEN "VT231 FOR GRAPHICS AS DEVICE #2 !Select_menu displayed on all devices DRAW Select_menu CLEAR #1 !Clear the display on dev #1 only 3 Syntax CLEAR [#dev-id] 2 CLOSE_DEVICE The CLOSE DEVICE statement allows you to explicitly close a specified device. Subsequent graphics output will not be displayed on this device. If all devices are closed and graphics output statements are executed, VAX BASIC opens the default device. Example OPEN "VTA247" FOR GRAPHICS AS DEVICE #2 OPEN "my_term" FOR GRAPHICS AS DEVICE #3 !+ !Display metafile on devices #2, and #3 !- GRAPH METAFILE "states_outline.pic" ! !Close device #2 ! CLOSE DEVICE #2 3 Syntax CLOSE DEVICE #dev-id 2 DEACTIVATE_DEVICE The DEACTIVATE DEVICE statement deactivates the specified output device. Subsequent graphics output will not be displayed on this device. If all devices have been deactivated and graphics output statements are executed, VAX BASIC reactivates the default device. Example OPTION TYPE = EXPLICIT EXTERNAL PICTURE demos, sample OPEN "BASIC_term" FOR GRAPHICS AS DEVICE #1 OPEN "my_vax" FOR GRAPHICS AS DEVICE #2 , TYPE 41 !+ !Display on all active devices !- DRAW demos DEACTIVATE DEVICE #2 !Display on device #1 only DRAW sample 3 Syntax DEACTIVATE DEVICE #dev-id 2 DRAW The DRAW statement invokes the specified PICTURE subprogram. Optional transformation functions allow you to invoke the picture with altered world coordinates. The order of the transformation functions affect the output displayed. For illustrations of the effects of each transformation function, see the DRAW statement in the reference section of the manual Programming with VAX BASIC Graphics. Example EXTERNAL PICTURE box(LONG) DRAW box(3) DRAW box(1) WITH SCALE(1.5,1.5) & * SHIFT(2,1) END 3 Syntax DRAW pic-name [ (param-list) ] [ WITH tran-term [ * tran-term]...] Tran-term: SCALE (real-var, [real-var]) SHEAR (angle) SHIFT (real-var, real-var} ROTATE (angle) TRANSFORM num-matrix 2 END_PICTURE The END PICTURE statement marks the end of a PICTURE subprogram. Example PICTURE sample PLOT LINES 0.0,0.0; & 0.0,0.2; & 0.5,0.2; & 0.5,0.0; & 0.0,0.0 END PICTURE 3 Syntax END PICTURE 2 EXIT_PICTURE The EXIT PICTURE statement allows you to terminate execution of a PICTURE subprogram. Example PICTURE sample(LONG pass) IF pass = 100% THEN GRAPH TEXT AT 0.1,0.7 : "Emergency exit" EXIT PICTURE END IF . . . END PICTURE 3 Syntax EXIT PICTURE 2 GET_POINT A GET POINT statement accepts a single point of user input. Points accepted with the GET POINT statement are affected by the transformation function associated with the DRAW statement, whereas points accepted with the LOCATE statement are not. The input point is transformed according to the transformation for the viewport that the point falls into. If the point falls into an area where more than one viewport is valid, VAX BASIC uses the transformation with the highest priority. Example DECLARE SINGLE user_x, user_y, & LONG which_tran SET WINDOW , TRAN 1 : 0,100,0,100 SET VIEWPORT , TRAN 1 : 0,0.5,0,0.5 !+ !Use TRAN 1 for initial point !- GET POINT , AT 50,50 USING TRAN 1 : user_x, user_y ,which_tran 3 Syntax GET POINT [ [#dev-id ] {:} ] [ ,UNIT int-exp ] [ ,AT x-coord,y-coord [USING TRAN int-exp] ] x-coord, y-coord [ ,int-var] 2 GRAPH_AREA The GRAPH AREA statement draws an area on all active devices. The sequence is determined by the coordinates supplied in the point list. Values for the attributes such as color and style use the current settings. You must specify at least three coordinate pairs with the GRAPH AREA statement. Example GRAPH AREA 0.1,0.8; 0.8,0.8; 0.5,0.2 3 Syntax GRAPH AREA [:] x-coord, y-coord, [;x-coord,y-coord]... 2 GRAPH_LINES The GRAPH LINES statement draws lines on all active devices. The sequence is determined by the coordinates supplied in the point list. Values for the attributes such as color and style use the current settings. You must specify the coordinates for at least two points the GRAPH LINES statement. Example GRAPH LINES 0.1,0.8; 0.8,0.8 3 Syntax GRAPH LINES [:] x-coord, y-coord, [;x-coord,y-coord]... 2 GRAPH_METAFILE Graphics images can be stored in files called metafiles. Metafiles provide you with a convenient means of storing and reproducing graphics images. They allow you to recreate an image without repeatedly processing the data. To create a metafile, you use the OPEN...FOR GRAPHICS statement specifying a file as device type 2. Output will be sent to the specified file. Once the metafile is created, it can be displayed with the GRAPH METAFILE statement. Example !+ !Open and send output to an output metafile !- OPEN "[MCKAY]swan.pic" FOR GRAPHICS AS DEVICE #1 , TYPE 2 EXTERNAL PICTURE swan DRAW swan CLOSE DEVICE #1 !+ !Display contents of metafile on default device !- GRAPH METAFILE "[MCKAY]swan.pic" END 3 Syntax GRAPH METAFILE file-spec 2 GRAPH_POINTS The GRAPH POINTS statement draws points on all active devices. The sequence is determined by the coordinates supplied in the point list. Values for the attributes such as color and style use the current settings. You must specify the coordinates for at least one point with the GRAPH POINTS statement. Example GRAPH POINTS 0.49,0.82; 0.82,0.82; 0.82,0.49 3 Syntax GRAPH POINTS [:] x-coord, y-coord, [;x-coord,y-coord]... 2 GRAPH_TEXT The GRAPH TEXT statement draws the specified characters. The display is governed by the current values of the text attributes HEIGHT, JUSTIFY, ANGLE, SPACE, EXPAND, FONT and PRECISION. When text is drawn within a picture, text attributes are not adjusted for any transformation function associated with the DRAW statement. If you set new window boundaries, you may need to adjust the text height. Example SET TEXT HEIGHT 0.05 GRAPH TEXT AT 0.0,0.8 : "How much of this fits on the screen?" 3 Syntax GRAPH TEXT [ , ] AT x-coord , y-coord : str-exp 2 LOCATE_CHOICE The LOCATE CHOICE statement accepts a user's selection from a menu. The menu items can be set with the SET INITIAL CHOICE statement. Example DECLARE LONG marital_status SET INITIAL CHOICE , LIST & ("Single", & "Divorced", & "Widowed", & "Married" & "Other") & : 3 !+ !Display menu, set a new initial choice and accept input !- LOCATE CHOICE , INITIAL 5 : marital_status 3 Syntax LOCATE CHOICE [ [#dev-id ] {:} ] int-var [ ,UNIT int-exp1 ] [ ,INITIAL int-exp2 ] 2 LOCATE_POINT A LOCATE POINT statement accepts a single point input by a user. Points accepted with the LOCATE POINT statement are not affected by the transformation function associated with the DRAW statement. The input point is transformed according to the transformation for the viewport that the point falls into. If the point falls into an area where more than one viewport is valid, VAX BASIC uses the transformation with the highest priority. Example OPTION TYPE = EXPLICIT EXTERNAL PICTURE boat(SINGLE,) DECLARE LONG alt_tran,which_tran, & REAL user_x, user_y !+ !Specify alternative transformation for initial point !- alt_tran = 2 !+ !Request coordinate pair from user and offer default point !- LOCATE POINT , AT 50,50 USING TRAN alt_tran : user_x, user_y , & which_tran 3 Syntax LOCATE POINT [ [#dev-id ] {:} ] [ ,UNIT int-exp1 ] [ ,AT x-coord, y-coord [ USING TRAN int-exp2 ] ] x-coord, y-coord [,int-var1] 2 LOCATE_STRING The LOCATE STRING statement accepts a user's string input. The user's string is concatenated to the initial string supplied in the INITIAL clause. Example OPTION TYPE = EXPLICIT DECLARE STRING init_string, user_string init_string = "YES" LOCATE STRING , INITIAL init_string : user_string 3 Syntax LOCATE STRING [ [#dev-id ] {:} ] str-var [ ,UNIT int-exp ] [ ,INITIAL str-exp ] 2 LOCATE_VALUE The LOCATE VALUE statement accepts a numeric value input by a user. Example DECLARE SINGLE limit1, limit2, your_number . . . LOCATE VALUE , RANGE limit1 TO limit2 & , INITIAL 2.5 & : your_number 3 Syntax LOCATE VALUE [ [#dev-id ] {:} ] real-var [ ,UNIT int-exp ] [ ,RANGE real-exp1 TO real-exp2 ] [ ,INITIAL real-exp3 ] 2 MAT_GRAPH The MAT GRAPH statement draws graphics output specified by the world coordinate points supplied in two arrays: an array of x-coordinate and an array of y-coordinate. The display is determined by the order of the coordinates supplied. The MAT GRAPH POINTS statement requires a minimum of one point. The MAT GRAPH LINES statement requires a minimum of two points and the MAT GRAPH AREA statement requires a minimum of three points. Objects that are drawn with the MAT GRAPH statement inside a picture definition, are not affected by the transformation functions associated with the DRAW statement. The output is drawn on all active devices. Values for the graphics attributes such as color and style depend on the current settings. Example PROGRAM letter_w DIM x_coords(6),y_coords(6) DATA 0.24,0.75, 0.3,0.45, 0.375,0.125, 0.5,0.55, & 0.625,0.125, 0.7,0.45, 0.76,0.75 READ x_coords(counter),y_coords(counter) FOR counter = 0% TO 6% !For illustration, the same coords are used !in each of the following MAT statements SET VIEWPORT ,TRAN 1 :0,0.5,0,0.5 MAT GRAPH POINTS x_coords, y_coords SET VIEWPORT ,TRAN 2 : 0,0.5,0.5,1 MAT GRAPH LINES x_coords, y_coords SET VIEWPORT ,TRAN 3 : 0.5,1,0.5,1 MAT GRAPH AREA x_coords, y_coords END PROGRAM 3 Syntax MAT GRAPH {POINTS} [ ,COUNT index: ] x-array, y-array {LINES } {AREA } 2 MAT_PLOT The MAT PLOT statement draws graphics output specified by the world coordinate points contained in arrays. The sequence of the points is determined by the order of the coordinates supplied. Points drawn with the MAT PLOT statement within a picture, are affected by the transformation functions included in a DRAW statement. Values for the graphics attributes such as color and style depend on the current settings. Example PICTURE points_w(SINGLE x_coords( ),y_coords( )) MAT PLOT POINTS x_coords, y_coords END PICTURE 3 Syntax MAT PLOT {POINTS} [ ,COUNT index: ] x-array, y-array {LINES } {AREA } 2 MAT...POINTS The MAT GET POINTS and MAT LOCATE POINTS statements accept one or more points input by a user. Points accepted with the MAT GET POINTS statement are not affected by the transformation function associated with the DRAW statement, whereas points accepted with the MAT LOCATE POINTS statement are. Example DECLARE LONG how_many DECLARE SINGLE user_x(12),user_y(12) MAT GET POINTS , COUNT how_many & : user_x, user_y MAT GRAPH POINTS , COUNT how_many & : user_x, user_y 3 Syntax MAT {GET } POINTS [ [#dev-id ] {:} ] {LOCATE} [ ,UNIT int-exp1 ] [ ,COUNT int-var1 ] [ ,AT x-coord, y-coord [USING TRAN int-exp3] ] x-array, y-array [ ,int-var] 2 OPEN...FOR_GRAPHICS The OPEN...FOR GRAPHICS statement opens and activates the specified device for graphics input or output. The quoted string must be a system or logical name for a device of the actual type specified or a file specification for a metafile. If no OPEN...FOR GRAPHICS statement is executed and graphics output statements are executed, VAX BASIC opens the default device. Example !Open a VSII OPEN "VT247" FOR GRAPHICS AS DEVICE #1 , TYPE 41 3 Syntax OPEN dev-name FOR GRAPHICS AS [ DEVICE ] #dev-id [ ,TYPE dev-type] 3 Device_types Each type of device that is supported by VAX GKS has a value associated with it. The following table lists the supported device types: DEVICE TYPE SUPPORTED DEVICE 0 Default device type 2 Output metafile 3 Input metafile 10 VT125 output only 11 VT125 with color 12 VT125 monochrome 13 VT240 with color 14 VT240 monochrome 15 LCP01 printer 31 LA34 with graphics option LA100 LA210 32 LA50 with 2:1 aspect ratio 33 LA12 41 VAXstation I VAXstation II monochrome VAXstation II/GPX color 51 LVP16 color plotter (8--1/2 by 11 paper) 52 LVP16 (11 by 17 paper 70 Tektronix 4014 output only 72 Tektronix 4014 2 PICTURE A PICTURE subprogram defines a graphics display and can be invoked with the DRAW statement. The PICTURE statement marks the start of a picture definition. Note that passing mechanisms should not be used when declaring parameters; pictures are VAX BASIC subprograms and use default passing mechanisms. Example PICTURE box(SINGLE left_1,right_1,bottom,top) PLOT LINES : left_1, top; & right_1, top; & right_1, bottom; & left_1, bottom; & left_1, top END PICTURE 3 Syntax PICTURE pic-name [(param-list)] statement [statement]... . . . END PICTURE 2 PLOT The PLOT statement draws the specified graphics object on all active devices. Values for graphics attributes such as color and style use the current settings. Graphics objects displayed with PLOT from within a picture, are affected by the specified transformation function, whereas those points displayed with GRAPH are not. The PLOT POINTS statement must include the coordinates for at least one point. The PLOT AREA statement requires a minimum of three points. However, with the PLOT LINES statement, you have the option of including no points or any number of points. The PLOT LINES statement lets you control whether the beam of light is switched on or off. When the beam of light is switched off, it is possible to move a plotter from one position to another without leaving a trail or a line. When the beam of light is switched on, a plotter draws a line as it moves from one position to the next. At the start of program execution, the beam of light is off. To leave the beam on, place a semicolon at the end of the last point in the PLOT LINES statement. To turn the beam off, use a PLOT LINES statement and do not include points or a semicolon after the last point. Example OPTION TYPE = EXPLICIT DECLARE SINGLE counter SET WINDOW 0,2*PI,-1,1 SET LINE SIZE 5 FOR counter = 0 TO 2*PI STEP 0.1 PLOT LINES counter, SIN(counter); NEXT counter PLOT LINES END 3 Syntax PLOT {POINTS} [:] x-coord, y-coord [; x-coord, y-coord]... {LINES } {AREA } 2 RESTORE_GRAPHICS The RESTORE GRAPHICS statement clears the current graphics environment and restores the default values as at the start of program execution. Example HANDLER cntrc_trap !Test if user entered CTRL/C IF ERR = 28% THEN RESTORE GRAPHICS !Restore original attributes and defaults CONTINUE END IF END HANDLER 3 Syntax RESTORE GRAPHICS 2 ROTATE The ROTATE function rotates points specified with PLOT statements in a PICTURE subprogram. Example OPTION ANGLE = RADIANS EXTERNAL PICTURE box(LONG) DRAW box(3) DRAW box(4) WITH ROTATE(0.25) DRAW box(1) WITH ROTATE(0.5) END 3 Syntax In the DRAW statement: DRAW pic-name [(param-list)] WITH ROTATE(angle) [ * matrix2]... In the MAT statement: MAT matrix1 = ROTATE (angle) [ * matrix2]... 2 SCALE The SCALE function applies a scale factor to the coordinates of points specified with PLOT statements in a PICTURE subprogram. Example EXTERNAL PICTURE box(LONG) DRAW box(3) DRAW box(1) WITH SCALE(1.5,1.5) END 3 Syntax In the DRAW statement: DRAW pic-name [(param-list)] WITH SCALE (real-exp1,[real-exp2]) [ * matrix2]... In the MAT statement: MAT matrix1 = SCALE (real-exp1,[real-exp2]) [ * matrix2]... 2 SHEAR The SHEAR function skews the x-coordinates of points specified with PLOT statements in a PICTURE subprogram. Example EXTERNAL PICTURE box(LONG) DRAW box(3) DRAW box(1) WITH SHEAR(0.25) END 3 Syntax In the DRAW statement: DRAW pic-name[(param-list)] WITH SHEAR(angle) [ * matrix2]... In the MAT statement: MAT matrix1 = SHEAR(angle) [ * matrix2]... 2 SHIFT The SHIFT function moves the coordinates of points specified with PLOT statements in a PICTURE subprogram. Example EXTERNAL PICTURE box(LONG) DRAW box(3) DRAW box(1) WITH SHIFT(-0.3,0) END 3 Syntax In the DRAW statement: DRAW pic-name[(param-list)] WITH SHIFT(real-exp1,real-exp2) [ * matrix2]... In the MAT statement: MAT matrix1 = SHIFT(real-exp1,real-exp2) [ * matrix2]... 2 SET_Statements You can use graphics SET statements to set various graphics attributes for your design such as color, size, and pattern or, to set text attributes such as fonts and text height. You can also use graphics SET statements to set the boundaries of the window and viewport, set transformations, and select items to be displayed in a menu. Note that the graphics SET statements are *not* synonymous with the SET command and therefore cannot be used in immediate mode. 3 AREA_STYLE The SET AREA STYLE statement lets you specify your choice of fill style for an area. The area style value can be one of four values: "HOLLOW", "SOLID", "PATTERN", or "HATCH". You can use lower- or uppercase letters because VAX BASIC converts the characters to uppercase. At the start of program execution, the area style is set to solid. Example OPTION TYPE = EXPLICIT EXTERNAL PICTURE sample SET AREA STYLE "HOLLOW" DRAW sample SET AREA STYLE "SOLID" DRAW sample WITH SHIFT(0.2,0) SET AREA STYLE "PATTERN" DRAW sample WITH SHIFT(0.4,0) SET AREA STYLE "HATCH" DRAW sample WITH SHIFT(0.6,0) END 4 Syntax SET AREA STYLE str-exp 3 AREA_STYLE_INDEX The SET AREA STYLE INDEX statement lets you specify your choice of index for hatch or pattern area fill styles. There is no index value for solid and hollow areas. Example OPTION TYPE = EXPLICIT DECLARE LONG variety EXTERNAL PICTURE sample SET AREA STYLE "hatch" FOR variety = 1 TO 10 STEP 2 SET AREA STYLE INDEX variety DRAW sample WITH SHIFT (0.1 * variety,0) NEXT variety END 4 Syntax SET AREA STYLE INDEX int-exp 3 CLIP The SET_CLIP statement lets you change the status of the clipping rectangle in the world viewport. The clipping status must be set to either "ON" or "OFF". At the start of program execution, clipping is set to ON. For more information on clipping, see the Programming with VAX BASIC Graphics manual. Example PROGRAM display EXTERNAL PICTURE BASIC_flag SET WINDOW 0,100,0,100 Screen1: SET CLIP "OFF" DRAW BASIC_flag SLEEP 4% CLEAR Screen2: SET CLIP "ON" DRAW BASIC_flag END PROGRAM 4 Syntax SET CLIP str-exp 3 ...COLOR The SET...COLOR statement allows you to specify a color for the specified graphics object. At the start of program execution, the foreground color index value is 1. Example PROGRAM samples DECLARE LONG CONSTANT green = 1 & ,red = 2 & ,blue = 3 SET LINE COLOR green GRAPH LINES 0.2,1; 0.2,0 SET POINT COLOR blue GRAPH POINTS 0.1,0.5; 0.3,0.5 SET AREA COLOR red GRAPH AREA 0.05,0.5; 0.5,0.8; & 0.35,0.5; 0.5,0.2 SET TEXT COLOR green GRAPH TEXT AT 0.6,0.5 : "Color me simple" END PROGRAM 4 Syntax SET {POINT} COLOR int-exp {LINE } {TEXT } {AREA } 3 COLOR_MIX The SET COLOR MIX statement allows you to specify the intensities for red, green, and blue for a particular color index. Example EXTERNAL PICTURE swan(LONG) . . . SET WINDOW 0,100,0,100 SET COLOR MIX #1 , INDEX 3 : 0.5700, 0.1400, 1.0000 DRAW swan(3) END 4 Syntax SET COLOR MIX [#dev-id] , INDEX int-exp : real-exp1, real-exp2, real-exp3 3 DEVICE_VIEWPORT The SET DEVICE VIEWPORT statement lets you change the boundaries of the device viewport, a portion of the display area. Boundaries must be specified as device coordinates. Example ASK DEVICE VIEWPORT left_1,right_1,bottom,top !Set the device window to half of NDC space SET DEVICE WINDOW 0,0.5,0,1 !Set the device viewport to the left half of the default SET DEVICE VIEWPORT left_1, right_1/2, bottom, top 4 Syntax SET DEVICE VIEWPORT [#dev-id : ] exp-list Exp-list must be four numeric expressions for the left, right, bottom and top boundaries. 3 DEVICE_WINDOW The SET DEVICE WINDOW statement lets you change the boundaries of the device window. The device window is a portion of NDC space you select to be displayed on the device viewport of an active device. Boundaries must be within the range 0 through 1. Example OPEN "VTA25" FOR GRAPHICS AS DEVICE #1 SET DEVICE WINDOW #1 : 0.5,1,0.5,1 4 Syntax SET DEVICE WINDOW [#dev-id : ] exp-list Exp-list must be four numeric expressions for the left, right, bottom and top boundaries. 3 ...ECHO_AREA The SET...ECHO AREA statements specify the boundaries (in device coordinates) of the echo area for the specified input type. Example OPTION TYPE = EXPLICIT DECLARE SINGLE left_1,right_1,bottom,top,input_value OPEN "office-term" FOR GRAPHICS AS DEVICE #1 ASK VALUE ECHO AREA #1 : left_1,right_1,bottom,top !Set the echo area to the top corner of the default area SET VALUE ECHO AREA #1 : left_1 + (right_1-left_1)/2 & ,right_1 & ,bottom + (top-bottom)/2 & ,top LOCATE VALUE #1 : input_value 4 Syntax SET {CHOICE} ECHO AREA [ [#dev-id ] {:} ] exp-list {STRING} [ ,UNIT int-exp ] {VALUE } Exp-list must be four numeric expressions for the left, right, bottom and top boundaries. 3 INITIAL_CHOICE The SET INITIAL CHOICE statement allows you to specify items to be displayed in a menu as well as supply an initial response for the user. Example DIM STRING menu_items(2) DECLARE LONG language menu_items(0) = "BASIC" menu_items(1) = "PASCAL" menu_items(2) = "C" SET INITIAL CHOICE , LIST menu_items & : 1 LOCATE CHOICE language 4 Syntax SET INITIAL CHOICE [ [#dev-id ] {:} ] [ ,UNIT int-exp1 ] [ ,COUNT int-exp2 ] [ ,LIST { str-array } ] [ { (str-exp [ ,str-exp ]...)} ] int-exp3 3 INITIAL_MULTIPOINT The SET INITIAL MULTIPOINT statement allows you to specify a set of initial points which a user can accept as the default input. You supply the world coordinates of these points. VAX BASIC uses the current transformation for output to display these points. You can only set a single initial point with the MAT LOCATE and MAT GET POINTS statements. Example DIM SINGLE maze_x(12), maze_y(12), & SINGLE input_xs(12), input_ys(12) SET WINDOW , TRAN 1 : 0,100,0,100 SET WINDOW , TRAN 2 : 500,1000,0,10 . . . SET INITIAL MULTIPOINT , COUNT 5 & , USING TRAN 1 & : maze_x, maze_y SET TRANSFORMATION 2 MAT LOCATE POINTS input_xs, input_ys 4 Syntax SET INITIAL MULTIPOINT [ [#dev-id ] {:} ] [ ,UNIT int-exp1 ] [ ,COUNT int-exp2 ] [ ,USING TRAN int-exp3 ] x-array, y-array 3 INITIAL_POINT The SET INITIAL POINT statement allows you to specify an initial point that a user can enter as the default input. You supply the world coordinates of this point. VAX BASIC uses the current transformation for output to display this initial point. Example EXTERNAL PICTURE circle(SINGLE,) DECLARE SINGLE center_x, center_y SET WINDOW , TRAN 1 : 0,100,0,100 SET WINDOW , TRAN 2 : 10,40,0,5 SET TRANSFORMATION 1 SET INITIAL POINT , USING TRAN 2 & : 20,3.5 GET POINT center_x, center_y DRAW circle(center_x, center_y) END 4 Syntax SET INITIAL POINT [ [#dev-id ] {:} ] x-coord, y-coord [ ,UNIT int-exp1 ] [ ,USING TRAN int-exp2 ] 3 INITIAL_STRING The SET INITIAL STRING statement allows you to specify an initial string expression that is presented to a user when string input is requested. A user can accept the initial string or enter another string. VAX BASIC concatenates the user-supplied string to the initial string. Example PROGRAM select_an_item DECLARE STRING users_string SET STRING ECHO AREA 240,767,0,240 SET INITIAL STRING "Enter YES or NO" LOCATE STRING users_string IF RIGHT$(users_string,17) = "YES" THEN DRAW Main_menu ELSE EXIT PROGRAM END IF 4 Syntax SET INITIAL STRING [ [#dev-id ] {:} ] str-exp [ ,UNIT int-exp ] 3 INITIAL_VALUE The SET INITIAL VALUE statement allows you to specify an initial floating-point number within a specified range. A user can enter this value or enter an alternative. Example DECLARE SINGLE which_val Input_rtn: SET INITIAL VALUE , RANGE 1 TO 30 & : 15 LOCATE VALUE which_val 4 Syntax SET INITIAL VALUE [ [ #dev-id ] {:} ] real-exp3 [ ,UNIT int-exp ] [ ,RANGE real-exp1 TO real-exp2 ] 3 INPUT_PRIORITY The SET INPUT PRIORITY statement allows you to specify which transformation should have the highest priority when interpreting input points from a device. Unless you include this statement, the current transformation is automatically the transformation with the highest input priority. Example SET WINDOW ,TRAN 2 : 0,100,0,100 SET TRANSFORMATION 1 MAT GRAPH POINTS xs, ys !Set highest priority to TRAN 2 for input SET INPUT PRIORITY 2 > 1 MAT GET POINTS : x_coords, y_coords 4 Syntax SET INPUT PRIORITY {int-var1 } { < } {int-var2 } {int-const1} { > } {int-const2} 3 ...SIZE The SET...SIZE statements allow you to select the current width of a line or size of a point. At the start of program execution, the size of the objects is set to the smallest size for that device. Example SET POINT SIZE 8 GRAPH POINTS 0.5,0.5 SET LINE SIZE 10 GRAPH LINES 0,0.2; 1,0.2 4 Syntax SET {LINE } SIZE num-exp {POINT} 3 ...STYLE The SET...STYLE statements let you specify your choice of style for a particular graphics object, such as the form of a line or the marker for a point. At the start of program execution, lines and areas are solid and points are represented by asterisks. Example PROGRAM Demo OPTION TYPE = EXPLICIT DECLARE LONG point_style, line_style FOR point_style = 1 TO 5 SET POINT STYLE point_style GRAPH POINTS point_style/10,0.8 NEXT point_style FOR line_style = 1 TO 4 SET LINE STYLE line_style GRAPH LINES 0,line_style/10; & 1,line_style/10 NEXT line_style END PROGRAM 4 Syntax SET {POINT} STYLE int-exp {LINE } 3 TEXT_ANGLE The SET TEXT ANGLE statement lets you change the angle with which a text string is rotated. Angles of either radians or degrees can be specified with the OPTION ANGLE statement. The default angle is zero. Example OPTION ANGLE = DEGREES SET TEXT FONT -3, "STROKE" SET TEXT HEIGHT 0.05 SET TEXT ANGLE 90 GRAPH TEXT AT 0.7,0.55 : "90 degrees" 4 Syntax SET TEXT ANGLE real-exp 3 TEXT_EXPAND The SET TEXT EXPAND statement lets you change the ratio of character width to height from the ratio defined in the original font design. The default expansion factor is 1. Example SET TEXT FONT -3, "STROKE" SET TEXT HEIGHT 0.05 SET TEXT EXPAND 3 GRAPH TEXT AT 0,0.8 : "Fat" SET TEXT EXPAND 1 GRAPH TEXT AT 0,0.6 : "Normal" SET TEXT EXPAND 0.5 GRAPH TEXT AT 0,0.4 : "Thin" 4 Syntax SET TEXT EXPAND real-exp 3 TEXT_FONT The SET TEXT FONT statement lets you select a font and optionally specify the level of precision with which the characters should be drawn. Possible values for the level of precision are "STRING", "CHAR", and "STROKE", in the order of increasing precision. STROKE precision uses software fonts. "CHAR" and "STRING" precision use hardware fonts. The initial precision value for all fonts is "STROKE". The default font varies with the actual device. Example SET TEXT FONT -8, "STROKE" 4 Syntax SET TEXT FONT int-exp [, str-exp] 3 TEXT_HEIGHT The SET TEXT HEIGHT statement lets you change the height of the characters in a font. Height refers to the height of the uppercase letters in world coordinates. The default text height is 0.035. After execution of a SET WINDOW statement, you may need to adjust the text height to suit the new boundaries. Example SET TEXT FONT -3, "STROKE" SET WINDOW 0,100,0,100 SET TEXT HEIGHT 5 GRAPH TEXT AT 0,50 : "BIG..." SET TEXT HEIGHT 8 GRAPH TEXT AT 12,50 : "BIGGER..." SET TEXT HEIGHT 12 GRAPH TEXT AT 47,50 :"BIGGEST..." 4 Syntax SET TEXT HEIGHT real-exp 3 TEXT_JUSTIFY The SET TEXT JUSTIFY statement allows you to change the values of the current horizontal and vertical components of text justification. The horizontal justification can be set to "LEFT", "CENTER", "RIGHT" or "NORMAL". The vertical justification can be set to "TOP", "CAP", "HALF", "BASE", "BOTTOM", or "NORMAL". Example SET TEXT JUSTIFY "CENTER" , "NORMAL" GRAPH TEXT AT 0.1,0.3 : "Center/normal" 4 Syntax SET TEXT JUSTIFY str-exp1, str-exp2 3 TEXT_PATH The SET TEXT PATH statement lets you specify the direction in which characters are drawn. You can specify a direction value of "RIGHT", "LEFT", "UP", or "DOWN". Example SET TEXT FONT -3, "STROKE" SET TEXT HEIGHT 0.05 SET TEXT PATH "UP" GRAPH TEXT AT 0.1,0.1 : "UP PATH" SET TEXT PATH "LEFT" GRAPH TEXT AT 0.7,0.9 : "LEFT PATH" SET TEXT PATH "DOWN" GRAPH TEXT AT 0.2,0.9 : "DOWN PATH" SET TEXT PATH "RIGHT" GRAPH TEXT AT 0.5,0.5 : "RIGHT PATH" 4 Syntax SET TEXT PATH str-exp 3 TEXT_SPACE The SET TEXT SPACE statement lets you change the spacing between characters drawn on an output device. Example !+ !Set text height to 5/100 of the default window !- SET TEXT HEIGHT 0.05 SET TEXT FONT -16, "STROKE" SET TEXT SPACE 0.09 GRAPH TEXT AT 0,0.8 : "These characters are far out" SET TEXT SPACE 0 GRAPH TEXT AT 0,0.6 : "This is the normal spacing" SET TEXT SPACE -0.09 GRAPH TEXT AT 0,0.4 : "These characters are tight" 4 Syntax SET TEXT SPACE real-exp 3 TRANSFORMATION The SET TRANSFORMATION statement explicitly establishes the transformation to be used for subsequent interpretations of world coordinate points. Example SET WINDOW , TRAN 1 : 0,10,0,10 SET VIEWPORT , TRAN 1 : 0,0.5,0,0.5 SET WINDOW , TRAN 2 : 500,1000,1,10 SET VIEWPORT ,TRAN 2 : 0.5,1,0.5,1 SET TRANSFORMATION 1 GRAPH AREA 2,8; 7,6; 3,1 SET TRANSFORMATION 2 GRAPH POINTS 800,2; 450,8; 475,8.5 4 Syntax SET TRANSFORMATION int-exp 3 VIEWPORT The SET VIEWPORT statement allows you to change the section of NDC space to which an image in the world window is mapped. A SET VIEWPORT statement implicitly establishes the current transformation. The default viewport is the entire NDC space with boundaries of 0,1,0,1. Example !Map all of window to top right corner of NDC space SET VIEWPORT , TRAN 2 : 0.5,1,0.5,1 4 Syntax SET VIEWPORT [ , TRAN int-exp : ] exp-list Exp-list must be four numeric expressions for the left, right, bottom and top boundaries. 3 WINDOW The SET WINDOW statement lets you change the boundary values (and therefore the coordinate measures) for the world window. The default window boundaries are 0,1,0,1. A SET WINDOW statement implicitly establishes the current transformation. When you set the window, you may need to adjust the text height. Example !+ !Each of these output statements displays the center point !of the window !The default window requires coordinates from 0 to 1 !- GRAPH POINTS 0.5,0.5 SET WINDOW , TRAN 1: 0,100,0,100 GRAPH POINTS 50,50 SET WINDOW , TRAN 2 : 25,525,0,1000 GRAPH POINTS 275,500 SET WINDOW , TRAN 3 : -1,1,-1,1 GRAPH POINTS 0,0 SET WINDOW , TRAN 4 : -50,0,0,900 GRAPH POINTS -25,450 4 Syntax SET WINDOW [ , TRAN int-exp : ] exp-list Exp-list must be four numeric expressions for the left, right, bottom and top boundaries. 2 TRANSFORM The TRANSFORM function returns the cumulative transformations for all transformation functions in nested picture invocations. VAX BASIC automatically invokes each picture with any cumulative transformation functions. Therefore, when you use a DRAW statement with the TRANSFORM function, nested in another picture, the cumulative transformations are applied twice. The TRANSFORM function can also be used to adjust the text height and the text starting position for a GRAPH TEXT statement inside a picture. Example PICTURE house EXTERNAL PICTURE door, outline !+ Door is actually drawn with SHIFT(2,1) * SHIFT(2,1) DRAW door WITH TRANSFORM DRAW outline END PICTURE PROGRAM draw_house EXTERNAL PICTURE house DRAW house WITH SHIFT(2,1) END PROGRAM 3 Syntax In the DRAW statement: DRAW pic-name[(param-list)] WITH TRANSFORM [ * matrix2]... In the MAT statement: MAT matrix1 = TRANSFORM [ * matrix2]...