home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Product / Product.zip / oncmd.zip / DEMOGRAP.PRG < prev    next >
Text File  |  1996-02-13  |  5KB  |  222 lines

  1. * Test all of the funky graphics and interactive functions
  2.  
  3. win = openwin(0,0,-1,-1, 'OnCmd ScreenSaver - Press any key or mouse click to end or c to Configure.' )
  4.  
  5. on click clickfun
  6.  
  7. do_lines = .t.
  8. do_squares = .t.
  9. do_circles = .t.
  10.  
  11. end_f = .t.
  12. do while end_f
  13.     if end_f .and. do_lines
  14.         do lineproc
  15.     endif
  16.     if end_f .and. do_squares
  17.         do box1
  18.     endif
  19.     if end_f .and. do_circles
  20.         do box2
  21.     endif
  22. enddo
  23. ***********************************
  24.  
  25. proc box1
  26. private mkey
  27. rand(ctot(time()))
  28. for i = 1 to 500
  29.     mkey = inkey( -1 )
  30.     if lower( chr( mkey ) ) = 'c'
  31.         on click
  32.         do configure
  33.         on click clickfun
  34.         if .not. do_squares
  35.             exit
  36.         endif
  37.     elseif mkey <> 0
  38.         end_f = .f.
  39.         exit
  40.     endif
  41.     x = abs(mod(rand(),78))
  42.     y = abs(mod(rand(),28))
  43.     l = abs(mod(rand(),78-x))
  44.     w = abs(mod(rand(),28-y))
  45.     c = abs(mod(rand(),10))
  46.     c1 = '0/' + ltrim(STR(c))
  47.     set color to &c1
  48.     @ y,x,y+w,x+l clear
  49. next i
  50. set color to n/w
  51. clear
  52. ***********************************
  53.  
  54. proc box2
  55. private mkey
  56. rand(ctot(time()))
  57. for i = 1 to 500
  58.     mkey = inkey(-1)
  59.     if lower( chr( mkey ) ) = 'c'
  60.         on click
  61.         configure()
  62.         on click clickfun
  63.         if .not. do_circles
  64.             exit
  65.         endif
  66.     elseif mkey <> 0
  67.         end_f = .f.
  68.         exit
  69.     endif
  70.     x = abs(mod(rand(),400))/10
  71.     y = abs(mod(rand(),130))/10
  72.     xs = abs(mod(rand(),400-x*10))/10+x
  73.     ys = abs(mod(rand(),130-y*10))/10+y
  74.     rx = abs(mod(rand(),xs-x))
  75.     ry = abs(mod(rand(),ys-y))
  76.  
  77.     c = abs(mod(rand(),9))
  78.     col = ltrim(str(c)) + '/n'
  79.     set color to &col
  80.     coord = mkarray(y,x,ys,xs)
  81.     box (coord, 1,rx,ry)
  82.     coord = mkarray(24-y,x,26-ys,xs)
  83.     box(coord,1,rx,ry)
  84.     coord = mkarray(24-y,80-x,26-ys,80-xs)
  85.     box(coord,1,rx,ry)
  86.     coord = mkarray(y,80-x,ys,80-xs)
  87.     box(coord,1,rx,ry)
  88. next i
  89. set color to n/w
  90. clear
  91. return
  92. ***********************************
  93.  
  94. proc lineproc
  95. private mkey
  96.     rand(ctot(time()))
  97.     n = 100
  98.     stepx = .5
  99.     stepy = .2
  100.     stepxs = .5
  101.     stepys = .2
  102.     x = abs(mod(rand(),800))/10
  103.     y = abs(mod(rand(),260))/10
  104.     xs = abs(mod(rand(),800-x*10))/10+x
  105.     ys = abs(mod(rand(),260-y*10))/10+y
  106.     declare trail[n,4]
  107.     count=1
  108. for k = 1 to 1000
  109.     mkey = inkey(-1)
  110.     if lower( chr( mkey ) ) = 'c'
  111.         on click
  112.         configure()
  113.         on click clickfun
  114.         if .not. do_lines
  115.             exit
  116.         endif
  117.     elseif mkey <> 0
  118.         end_f = .f.
  119.         exit
  120.     endif
  121.     c = abs(mod(rand(),9))
  122.     col = ltrim(str(c)) + '/n'
  123.     set color to &col
  124.     coord = mkarray(y,x,ys,xs)
  125.     line (coord)
  126.     if count < n + 1
  127.         trail[count][1] = y
  128.         trail[count][2] = x
  129.         trail[count][3] = ys
  130.         trail[count][4] = xs
  131.     else
  132.         coord = mkarray(trail[1][1],trail[1][2],trail[1][3],trail[1][4])
  133.         set color to 'w/w'
  134.         line( coord )
  135.         for i = 1 to n-1
  136.             trail[i][1] = trail[i+1][1]
  137.             trail[i][2] = trail[i+1][2]
  138.             trail[i][3] = trail[i+1][3]
  139.             trail[i][4] = trail[i+1][4]
  140.         next i
  141.         trail[n][1] = y
  142.         trail[n][2] = x
  143.         trail[n][3] = ys
  144.         trail[n][4] = xs
  145.     endif
  146.     count = count + 1
  147.  
  148.     x = x + stepx
  149.     y = y + stepy
  150.     xs = xs + stepxs
  151.     ys = ys + stepys
  152.     if x > 80 .OR. x < 0
  153.         stepx = stepx * -1
  154.     endif
  155.     if y >28 .OR. y < 0
  156.         stepy = stepy * -1
  157.     endif
  158.     if xs > 80 .OR. xs < 0
  159.         stepxs = stepxs * -1
  160.     endif
  161.     if ys >28 .OR. ys < -1
  162.         stepys = stepys * -1
  163.     endif
  164.  
  165. next k
  166. clear
  167. ***********************************
  168.  
  169. func clickfun
  170. quit
  171. ***********************************
  172.  
  173. func configure
  174.  
  175. private my_win = openwin( 10, 10, 15, 31, 'Configure Screen Saver' )
  176. private my_quit = .f.
  177. private my_reset = .f.
  178. private my_all = .f.
  179. private my_lines = do_lines
  180. private my_squares = do_squares
  181. private my_circles = do_circles
  182. set color to n/p
  183. clear
  184. @ 2,11 get my_lines picture '@*C Lines' color n/p
  185. @ 4,11 get my_squares picture '@*C Squares' color n/p
  186. @ 6,11 get my_circles picture '@*C Ovals' color n/p
  187. @ 9,2 get my_all picture '@*T ~All' color n/p size 2,8
  188. @ 9,11 get my_reset picture '@*T ~Reset' color n/p size 2,8
  189. @ 9,20 get my_quit picture '@*TD ~OK' color n/p size 2,8
  190. set fullread on
  191. private mylf = 0
  192. do while .not. my_quit
  193.     read save from mylf
  194.     mylf = lastfield()
  195.     if my_reset .or. my_all
  196.         if my_reset
  197.             my_lines = do_lines
  198.             my_squares = do_squares
  199.             my_circles = do_circles
  200.         else
  201.             my_lines = .t.
  202.             my_squares = .t.
  203.             my_circles = .t.
  204.         endif
  205.         showgets()
  206.         my_reset = .f.
  207.         my_all = .f.
  208.     elseif my_quit
  209.         if .not. my_lines .and. .not. my_squares .and. .not. my_circles
  210.             msgbox( 'Configure Screen Saver', 'Must indicate at least one of Lines, Squares, and Circles', 7 )
  211.             my_quit = .f.
  212.         else
  213.             do_lines = my_lines
  214.             do_squares = my_squares
  215.             do_circles = my_circles
  216.         endif
  217.     endif
  218. enddo
  219. closewin( my_win )
  220. return
  221. ***********************************
  222.