palette statement...

Date: 01-25-93 (20:43)             Number: 37
From: TIM PETERSON #145 @5930      Refer#: NONE
  To: ALL                           Recvd: NO  
Subj: palette statement...           Conf: (17) QuickBASIC

OooOpS! So sue me. I got the color order wrong. The correct way to define new colors is: PALETTE coloryouwanttochange , red+(green*256)+(blue*65536) PALETTE 0 , 4144959 would change the background color(color 0) to white. Red, blue and green can be any interger value from 0 to 63. The complement of a color can be found by subtracting its' color value from white(4144959). You can even change the colors in text mode if you have ega, mcga, or vga. I dunno why you would want to since you would be limited to the standard colors. Might be useful for adding user defined colors to a program without changing all tyhe COLOR statements. One thing I fergot to cover is the PALETTE USING statement. This allows you to change the entire palette with one command. The command sort of downloads a whole palette from an array. This works fine in screen 11, or even in screen 9, but is pretty slow in screen 13, at least on the 386sx16. I send bytes directly to the vga card for speed, but I do get a bit of "snow" when I do it. To use the PALETTE USING statement, you must first DIM an array and fill it with color values. Well, I guess you don't have to put colors in it first if you want all of your colors to be black! The array must be at least large enough to hold a complete palette for the mode you are working in(16 for screen 11, 256 for screen 13, etc...). One nifty feature is that if you put -1 into a location in the array, that color is not changed, even if you have already changed it. Another feature is that you don't have to start at the beginning of an array. You can use an INDEX parameter to tell qb to start reading the palette values from other than the first element of the array. Like this: PALETTE USING arrayname(index) Say you are in screen 11 (640x480x16colors). If you DIM an array to 32 elements, say DIM colorarray(31), then PALETTE USING colorarray would load the first 16 values, while PALETTE USING colorarray(16) would load the second 16 values. Try this: screen11 line(300,200)-(340,280),1,BF for red=0 to 63 for green = 0 to 63 for blue = 0 to 63 PALETTE 1,red+(green*256)+(blue*65536) next next next this will run through all 256k(262,144) colors. It may take awhile. In fact, you can add some timing statements and use it to "benchmark" your computer and video card. If you add this line; PALETTE 0,4144959-(red+(green*256)+(blue*65536)) right before the first NEXT statement, the background will always be the comlimentary color. [0m [31m Tim Peterson [0m
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET