- This wiki is out of date, use the continuation of this wiki instead
Rgb
From FenixWiki
Contents |
Definition
WORD rgb ( <BYTE red> , <BYTE green> , <BYTE blue> )
Finds the single color in the current color mode closest to the combined red, green, and blue values specified.
Parameters
BYTE red | - Level of red in the desired color from 0 to 255. |
BYTE green | - Level of green in the desired color from 0 to 255. |
BYTE blue | - Level of blue in the desired color from 0 to 255. |
Returns
WORD : Returns the best matched color code.
Notes
Different color depths have different color codes, this is why rgb() is useful: it returns the appropriate code, based on the current color depth. When in 8bit mode, this code is 0..255 and when in 16bit mode 0..65535.
Using this function in different color depths can be tricky. This is because rgb() will return a different color code under different color depths. For example, when at 8bit, we do:
my_color = rgb(100,100,100);
my_color will most likely have the value 6 at this time. Suppose we change the color depth to 16bit now, using set_mode(). Now, my_color holds a totally different color than before, as 6 is nowhere near rgb(100,100,100) in 16bit mode. To counter this effect, my_color needs to be reinitialized:
my_color = rgb(100,100,100);
The same code, but rgb() now returns the proper code, as it always returns the code belonging to the current color depth. my_color will now be about 25388.
Example
Program awesome; Global red=0; green=255; blue=0; Begin set_text_color(rgb(red,green,blue)); // rgb finds the color closest to pure green and // passes it to set_text_color write(0,1,1,0,"Mijn potlood is bruin"); //this text will be green as an Irishman's ejecta Loop frame; End End