home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_01 / HISOFT.LZH / HISOFT_A.MSA / TUTORIAL / ABC.BAS next >
BASIC Source File  |  1991-10-07  |  2KB  |  81 lines

  1. REM A general version of the GEM example
  2. REM in the HiSoft BASIC 2 manual.
  3. REM This should work in any resolution.
  4.  
  5. defint a-z
  6. library "gemvdi"
  7.  
  8. REM Length of the box, depth (skew) and letter height
  9. const length=50,skew=20,ch_height=32
  10.  
  11. b$="HiSoft BASIC 2"
  12.  
  13. dim ch(7)
  14.  
  15. 'REM Draws a 3D box with top left at (x,y)
  16. 'REM and places the letter ch$ in the centre
  17.  
  18. SUB draw_box (BYVAL x,BYVAL y,BYVAL ch$)
  19. LOCAL pts(11)
  20. shared ch_x,ch_y
  21.  
  22.     pts(0)=x : pts(1)=y
  23.     pts(2)=x+skew : pts(3)=y-skew
  24.     pts(4)=x+length+skew : pts(5)=y-skew
  25.     pts(6)=x+length+skew : pts(7)=y+length-skew
  26.     pts(8)=x+length : pts(9)=y+length
  27.     pts(10)=x : pts(11)=y+length
  28.  
  29.     v_fillarea 6,pts()
  30.  
  31.     pts(2)=x+length : pts(3)=y
  32.     pts(4)=x+length+skew : pts(5)=y-skew
  33.     v_pline 3,pts()
  34.  
  35.     pts(0)=x+length : pts(1)=y+length
  36.     v_pline 2,pts()
  37.  
  38.     v_gtext x+(length-ch_x)/2, y+(length+ch_y)/2, ch$
  39.  
  40. end sub
  41.  
  42. REM Initialisation. Works out the window size and
  43. REM sets up global variables accordingly.
  44. REM Also works out the character height and therefore
  45. REM where to position the b_string string.
  46. sub init
  47. STATIC xmax, ymax, wx, wy, ww, wh, b_width, b_height
  48. local ch(7)
  49. shared xstart, ystart, b_x, b_y, ch_x, ch_y, b$
  50.  
  51.     WINDOW GET 2,1,wx,wy,ww,wh
  52.     xmax=ww-wx : ymax=wh-wy
  53.     xstart=xmax/2-(2*length+length/6+skew)/2
  54.     ystart=ymax/2
  55.  
  56.     vsf_color 1
  57.     vsf_interior 0
  58.     vst_height ch_height
  59.  
  60.     vqt_extent "A",ch()
  61.     ch_y=ch(7)-ch(1)
  62.     ch_x=ch(2)-ch(0)
  63.  
  64.     b_width=len(b$)*ch_x
  65.     b_height=ch_y
  66.     b_x=xmax/2-b_width/2
  67.     b_y=ystart+length+3*b_height/2
  68.  
  69. end sub
  70.  
  71. REM Initialise variables etc.
  72. init
  73.  
  74. REM Draw 3 boxes with B, C and A in them.
  75. draw_box xstart,ystart,"B"
  76. draw_box xstart+7*length/6,ystart,"C"
  77. draw_box xstart+7*length/12,ystart-7*length/6,"A"
  78.  
  79. REM Draw the title string.
  80. v_gtext b_x,b_y,b$
  81.