home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 63 / CDACTUAL63.iso / Aplicaciones / DarkBasic / DemoDarkBasic.exe / help / examples / 2d / exam07.dba < prev    next >
Encoding:
Text File  |  2000-04-09  |  2.0 KB  |  87 lines

  1. Rem * Title  : Getting pixel data
  2. Rem * Author : DBS-MB
  3. Rem * Date   : 1st August 99
  4. rem ========================================
  5. rem DARK BASIC EXAMPLE PROGRAM 7
  6. rem ========================================
  7. rem This program will use the point command 
  8. rem ----------------------------------------
  9.  
  10. rem Draw some random boxs on screen
  11. gosub myrandombox
  12.  
  13. rem Set the ink to white and paper color to black 
  14. ink rgb(244,214,210),0
  15.  
  16. rem Wait for the right mouse button to be pressed 
  17. x=0
  18. y=0
  19. repeat
  20.  
  21.     rem Show colour values
  22.     if x<>mousex() or y<>mousey()
  23.         gosub drawwhatcolor
  24.     endif
  25.  
  26.     rem Record current mouse position
  27.     x=mousex()
  28.     y=mousey()        
  29.  
  30.     rem Get color under mouse pointer
  31.     color=point(x,y)
  32.  
  33. until mouseclick()=1
  34.  
  35. rem Set the ink to white and paper color to black 
  36. ink rgb(244,214,210),1
  37.  
  38. rem Print a message on screen
  39. text 200,240,"press the spacebar to quit"
  40.  
  41. rem Will wait for you to press any key
  42. suspend for key
  43.  
  44. rem End the program
  45. end
  46.  
  47. drawwhatcolor:
  48. rem *************************************************************************
  49. rem * print a message on screen tell you what color is under mouse pointer *
  50. rem *************************************************************************
  51.  
  52. rem Set the ink to black and paper color to black 
  53. ink 1,1
  54.  
  55. rem draw a black box on screen which will clear away old message
  56. box 0,465,639,479
  57.  
  58. rem Set the ink to white and paper color to black 
  59. ink rgb(244,214,210),1
  60.  
  61. rem draw new message
  62. text 0,465,"color under mouse is "+" r:"+str$(rgbr(color))+" g:"+str$(rgbg(color))+" b:"+str$(rgbb(color))
  63.  
  64. return
  65.  
  66. myrandombox:
  67. rem ***************************
  68. rem * Draw 100 boxs on screen *
  69. rem ***************************
  70.  
  71. for t=0 to 100 
  72.     rem Get a random ink color
  73.     ink rgb(rnd(255),rnd(255),rnd(255)),1
  74.     
  75.     rem where on screen to draw box
  76.  
  77.     rem Start of line
  78.     left=rnd(640)
  79.     top=rnd(480)
  80.     right=left+50
  81.     bottom=top+50
  82.     
  83.     rem Draw a box
  84.     box left,top,right,bottom
  85. next t
  86. return
  87.