'taken from SimpleSi's QuickBasic/QBasic Page 'http://www.geocities.com/SiliconValley/Pines/5738/index.htm '*** Program to fade in and out multiple lines of text. '*** Or fade in and out a screen. '*** Any questions? Reach me at 'dkostka@salsgiver.com' '*** Please note that these are two totally different examples and they ' don't need to be used together. Textdemo: '*** This one will fade in and out text only. DIM Text(10) AS STRING Clr = 15 '*** Palette index color to use SlpDly = .1 '*** Number of seconds to show each line BluClr = 63 '*** These define the color that the text will be. GrnClr = 63 ' The numbers can be from 0 to 63, 63 being the RedClr = 63 ' brightest. ST = .05'SPEED Text(1) = "This is an example of how to fade in and out text." Text(2) = "In order to do this, first set the color you're using to black," Text(3) = "then gradually bring it back to normal color. If you want" Text(4) = "several faded message, then gradually make it black again," Text(5) = "then print the next message, and bring it to normal color." CLS COLOR Clr SCREEN 12 PALETTE Clr, 0 FOR A = 1 TO 5 CLS PRINT Text(A) FOR I = .001 TO 1 STEP ST PALETTE Clr, 65536 * INT(BluClr * I) + 256 * INT(GrnClr * I) + INT(RedClr * I) NEXT I 'SLEEP SlpDly FOR I = .999 TO 0 STEP -ST PALETTE Clr, 65536 * INT(BluClr * I) + 256 * INT(GrnClr * I) + INT(RedClr * I) NEXT I NEXT A SCREEN 0 SLEEP GOTO Fadedemo END Fadedemo: SCREEN 12 '*** First we need something on the screen. FOR I = 1 TO 200 LINE (INT(RND * 640) + 1, INT(RND * 480) + 1)-(INT(RND * 640) + 1, INT(RND * 480) + 1), INT(RND * 16) NEXT I '*** These set the color intensities to arrays. This is the normal palette ' so son't worry if you can't understand it. This will only work in ' screen mode having at least 16 colors. For screen modes withe more, ' it will only fade the first 16. DIM Red(16) Red(1) = 0: Red(2) = 0: Red(3) = 0: Red(4) = 0: Red(5) = 42: Red(6) = 42 Red(7) = 42: Red(8) = 42: Red(9) = 21: Red(10) = 21: Red(11) = 21: Red(12) = 21 Red(13) = 63: Red(14) = 63: Red(15) = 63: Red(16) = 63 DIM Green(16) Green(1) = 0: Green(2) = 0: Green(3) = 42: Green(4) = 42: Green(5) = 0: Green(6) = 0 Green(7) = 21: Green(8) = 42: Green(9) = 21: Green(10) = 21: Green(11) = 63: Green(12) = 63 Green(13) = 21: Green(14) = 21: Green(15) = 63: Green(16) = 63 DIM Blue(16) Blue(1) = 0: Blue(2) = 42: Blue(3) = 0: Blue(4) = 42: Blue(5) = 0: Blue(6) = 42 Blue(7) = 0: Blue(8) = 42: Blue(9) = 21: Blue(10) = 63: Blue(11) = 21: Blue(12) = 63 Blue(13) = 21: Blue(14) = 63: Blue(15) = 21: Blue(16) = 63 '*** This part fades the palette out FOR I = .99 TO 0 STEP -ST FOR A = 0 TO 15 PALETTE A, 65536 * INT(Blue(A + 1) * I) + 256 * INT(Green(A + 1) * I) + INT(Red(A + 1) * I) NEXT A NEXT I '*** This fades the palette in FOR I = .01 TO 1 STEP ST FOR A = 0 TO 15 PALETTE A, 65536 * INT(Blue(A + 1) * I) + 256 * INT(Green(A + 1) * I) + INT(Red(A + 1) * I) NEXT A NEXT I END