This wiki is out of date, use the continuation of this wiki instead

Set text color

From FenixWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 22:44, 27 June 2007 (edit)
Sandman (Talk | contribs)
m
← Previous diff
Revision as of 19:24, 23 July 2007 (edit) (undo)
Rincewind (Talk | contribs)
(Overhaul)
Next diff →
Line 5: Line 5:
'''INT''' set_text_color ( <'''WORD''' color> ) '''INT''' set_text_color ( <'''WORD''' color> )
-Sets the [[color]] of texts written after this [[function]] is called.+Sets the current text color (the color where texts will be written in). This only affects 1 bit (2 color) fonts, which can be loaded with [[load_font]]() or [[load_bdf]](). 8 bit and 16 bit fonts already contain color information themselves and thus aren't affected.
 + 
== Parameters == == Parameters ==
{| {|
-| '''WORD''' color || - The color to use for text.+| '''WORD''' color || - The color to use for text. In 8 bit color mode, the color corresponds with the palette index (0-255), and in 16 bit color mode the color corresponds with a RGB value. Value can be acquired by use of [[get_RGB]]().
|} |}
== Returns == == Returns ==
'''INT''' : [[true]] if successful and [[false]] if failed. (''Needs confirmation.'') '''INT''' : [[true]] if successful and [[false]] if failed. (''Needs confirmation.'')
 +
 +== Notes ==
 +Be warned that values returned by the [[RGB]]() function differ with the video card. So, directly filling out color numbers as color parameter in 16 bit color mode without using [[RGB]]() is a bad idea, as RGB returns the correct color code for every video card
 +
 +== Errors ==
 +''<If someone knows, please edit!> ''
== Example == == Example ==
Line 38: Line 45:
</pre> </pre>
Used in example: [[write]](), [[rgb]]() Used in example: [[write]](), [[rgb]]()
 +
 +This results in something like this: <br/>
 +[[Image:set_text_color.png]]

Revision as of 19:24, 23 July 2007


Contents

Definition

INT set_text_color ( <WORD color> )

Sets the current text color (the color where texts will be written in). This only affects 1 bit (2 color) fonts, which can be loaded with load_font() or load_bdf(). 8 bit and 16 bit fonts already contain color information themselves and thus aren't affected.


Parameters

WORD color - The color to use for text. In 8 bit color mode, the color corresponds with the palette index (0-255), and in 16 bit color mode the color corresponds with a RGB value. Value can be acquired by use of get_RGB().

Returns

INT : true if successful and false if failed. (Needs confirmation.)

Notes

Be warned that values returned by the RGB() function differ with the video card. So, directly filling out color numbers as color parameter in 16 bit color mode without using RGB() is a bad idea, as RGB returns the correct color code for every video card

Errors

<If someone knows, please edit!>

Example

Program awesome;
Global
    byte red=0;
    byte green=255;
    byte blue=0;

Begin
    
    set_text_color(rgb(red,green,blue));
    write(0,1,1,0,"Mijn potlood is bruin"); //this text will be green as an Irishman's ejecta

    set_text_color(rgb(255,0,0));
    write(0,1,11,0,"Je moeder"); //this text will be red
        
    Loop
  
        frame;
    End
End

Used in example: write(), rgb()

This results in something like this:
Image:set_text_color.png

Personal tools