home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l196 / 3.ddi / PALETTE.BA$ / PALETTE.bin
Encoding:
Text File  |  1990-06-24  |  1.7 KB  |  56 lines

  1. DECLARE SUB InitPalette ()
  2. DECLARE    SUB ChangePalette ()
  3. DECLARE    SUB DrawEllipses ()
  4.  
  5. DEFINT A-Z
  6. DIM SHARED PaletteArray(15)
  7.  
  8. SCREEN 8         ' 640 x 200 resolution; 16 colors
  9.  
  10. InitPalette         ' Initialize PaletteArray.
  11. DrawEllipses         ' Draw and paint concentric ellipses.
  12.  
  13. DO             ' Shift the palette until a key
  14.    ChangePalette     ' is pressed.
  15. LOOP WHILE INKEY$ = ""
  16.  
  17. END
  18.  
  19. ' ====================== InitPalette ======================
  20. '    This procedure initializes the integer array used to
  21. '    change the palette.
  22. ' =========================================================
  23. SUB InitPalette    STATIC
  24.    FOR I = 0 TO    15
  25.       PaletteArray(I) =    I
  26.    NEXT    I
  27. END SUB
  28.  
  29. ' ===================== DrawEllipses ======================
  30. '    This procedure draws 15 concentric ellipses and
  31. '    paints the interior of each with a different color.
  32. ' =========================================================
  33. SUB DrawEllipses STATIC
  34.    CONST ASPECT    = 1 / 3
  35.    FOR ColorVal    = 15 TO    1 STEP -1
  36.       Radius = 20 * ColorVal
  37.       CIRCLE (320, 100), Radius, ColorVal, , , ASPECT
  38.       PAINT (320, 100),    ColorVal
  39.    NEXT
  40. END SUB
  41.  
  42. ' ===================== ChangePalette =====================
  43. '  This procedure rotates the palette by one each time it
  44. '  is called. For example, after the first call to
  45. '  ChangePalette, PaletteArray(1) = 2, PaletteArray(2) = 3,
  46. '  . . . , PaletteArray(14) = 15, and PaletteArray(15) = 1
  47. ' =========================================================
  48. SUB ChangePalette STATIC
  49.    FOR I = 1 TO    15
  50.       PaletteArray(I) =    (PaletteArray(I) MOD 15) + 1
  51.    NEXT    I
  52.    PALETTE USING PaletteArray(0) ' Shift the color displayed
  53.                  ' by each of the attributes.
  54. END SUB
  55.  
  56.