home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 106 / EnigmaAmiga106CD.iso / www / afc / afc-dir / palette_examples.lha / Examples / Palette_Example1.e < prev   
Text File  |  1998-01-17  |  1KB  |  83 lines

  1. /*
  2.  
  3.     $VER: Palette Example 1 - (C)Amiga Foundation Classes
  4.  
  5.     Written By: Fabio Rotondo
  6.  
  7.     This source code is public domain.
  8.  
  9. */
  10.  
  11. MODULE 'afc/palette', 'afc/explain_exception',
  12.        'intuition/screens', 'intuition/intuition'
  13.  
  14. PROC main() HANDLE
  15.   DEF pal:PTR TO palette
  16.   DEF r,g,b, scr=NIL:PTR TO screen
  17.   DEF x,y, col=0
  18.  
  19.   NEW pal.palette()
  20.  
  21.   pal.setRGB(0, 0,   0,   0)
  22.   pal.setRGB(1, 255, 0,   0)
  23.   pal.setRGB(2, 0, 254,   0)
  24.   pal.setRGB(3, 0,   0, 255)
  25.   r,g,b:=pal.getRGB(2)
  26.  
  27.   WriteF('R:\d G:\d B:\d\n', r,g,b)
  28.  
  29.  
  30.   WriteF('Grabbing the WB Palette...\n')
  31.   pal.grab(LockPubScreen('Workbench'))
  32.  
  33.   IF (scr:=OpenScreenTagList(NIL, [SA_WIDTH,  320,
  34.                                    SA_HEIGHT, 256,
  35.                                    SA_DEPTH,    8,
  36.                                    NIL, NIL]))=NIL THEN Raise("scr")
  37.  
  38.   pal.setPal(scr)
  39.  
  40.   FOR y:=0 TO 239
  41.     FOR x:=0 TO 239
  42.       SetAPen(scr.rastport, col++)
  43.       RectFill(scr.rastport, x, y, x+8, y+8)
  44.       x:=x+8
  45.     ENDFOR
  46.     y:=y+8
  47.   ENDFOR
  48.  
  49.   waitMouse()
  50.  
  51.  
  52.   WriteF('Every color is White...\n')
  53.   FOR x:=0 TO 255
  54.     pal.loadRGB(scr, x, 255, 255, 255)
  55.   ENDFOR
  56.  
  57.   pal.loadRGB(scr,   0, 0,0,0)
  58.  
  59.   waitMouse()
  60.  
  61.  
  62.   WriteF('And now: a spread!\n')
  63.   pal.spread(0, 230)
  64.   pal.setPal(scr)
  65.  
  66.   waitMouse()
  67.  
  68. EXCEPT DO
  69.   IF scr THEN CloseScreen(scr)
  70.   END pal
  71.   explain_exception()
  72. ENDPROC
  73.  
  74. PROC waitMouse()
  75.   REPEAT
  76.     Delay(5)
  77.   UNTIL Mouse()
  78.  
  79.   REPEAT
  80.   UNTIL Mouse()=0
  81.  
  82. ENDPROC
  83.