'=========================================================================== ' Subject: STORE COLOR PALETTES Date: 11-16-95 (13:27) ' Author: The ABC Programmer Code: QB, QBasic, PDS ' Keys: STORE,COLOR,PALETTES Packet: GRAPHICS.ABC '=========================================================================== '======================================================= ' STORE COLOR PALETTES IN ARRAYS By William Yu (11/1995) ' Demonstrates the use of Palletes in Screen 13 '======================================================= DECLARE SUB ChangePal (Colour(), Reverse, Start) DIM Blue(16), Red(16), Green(16) DIM White(16) DIM Yellow(16) DIM Purple(16) DIM Cyan(16) DIM Orange(16) DIM Pink(16) False = 0 True = NOT False SCREEN 13 N = 1 FOR X = 1 TO 48 STEP 3 Blue(N) = 65536 * (X + 5) + 256 Red(N) = 65536 + 256 + (X + 5) Green(N) = 65536 + 256 * (X + 5) White(N) = 65536 * (X + 12) + 256 * (X + 12) + (X + 12) Yellow(N) = 65536 + 256 * (X + 15) + (X + 15) Purple(N) = 65536 * (X + 15) + 256 + (X + 15) Cyan(N) = 65536 * (X + 15) + 256 * (X + 15) Orange(N) = 65536 + 256 * (X + 1) + (X + 17) IF X < 28 THEN Pink(N) = 65536 * (X + 10) + 256 * (X + .1) + (X + 10) ELSE Pink(N) = Pink(N - 8) END IF PALETTE N, Blue(N) PALETTE N + 16, Red(N) PALETTE N + 32, Green(N) PALETTE N + 48, White(N) PALETTE N + 64, Yellow(N) PALETTE N + 80, Purple(N) PALETTE N + 96, Cyan(N) PALETTE N + 112, Orange(N) PALETTE N + 128, Pink(N) LOCATE 1, N: COLOR N: PRINT "Û" LOCATE 2, N: COLOR N + 16: PRINT "Û" LOCATE 3, N: COLOR N + 32: PRINT "Û" LOCATE 4, N: COLOR N + 48: PRINT "Û" LOCATE 5, N: COLOR N + 64: PRINT "Û" LOCATE 6, N: COLOR N + 80: PRINT "Û" LOCATE 7, N: COLOR N + 96: PRINT "Û" LOCATE 8, N: COLOR N + 112: PRINT "Û" LOCATE 9, N: COLOR N + 128: PRINT "Û" N = N + 1 NEXT X LOCATE 11, 1: PRINT "Watch while I switch the all the" PRINT "palettes to green with CHANGEPAL" X = 1 FOR I = 1 TO 9 ChangePal Green(), False, X X = X + 16 NEXT I COLOR 47: PRINT "Now let's go backwards!" X = 129 FOR I = 1 TO 9 ChangePal Orange(), True, X X = X - 16 NEXT I COLOR 63: PRINT "Watch while I reverse the process." FOR N = 1 TO 16 PALETTE N, Blue(N) PALETTE N + 16, Red(N) PALETTE N + 32, Green(N) PALETTE N + 48, White(N) PALETTE N + 64, Yellow(N) PALETTE N + 80, Purple(N) PALETTE N + 96, Cyan(N) PALETTE N + 112, Orange(N) PALETTE N + 128, Pink(N) NEXT N LOCATE 17: COLOR 95: PRINT "Play around with the palettes, have fun!" END ' ' Colour() can be any one of the defined array colour types ' Reverse can either be TRUE or FALSE ' if True, the palette changes from high intensity to low ' if False, the palette changes from low to high intensity ' Start can be any integer from which you wish to define the paletted ' color to (Remember that an array has 16 paletted colors) ' So if you start from 1 it'll stop at 16 ' The next starting point would be 17 and so on... ' SUB ChangePal (Colour(), Reverse, Start) IF Reverse THEN FOR I = Start + 15 TO Start STEP -1 PALETTE I, Colour(I - Start + 1) NEXT I ELSE FOR I = Start TO Start + 15 PALETTE I, Colour(I - Start + 1) NEXT I END IF END SUB