Difference between revisions of "gc:setColorRGB"

From Inspired-Lua Wiki
Jump to navigation Jump to search
(Created page with "gc:'''setColorRGB''' is a function that is part of the gc (Graphics Context). It sets the color of subsequent ''draw'' and ''fill'' operations. {{Since|3.0}} ...")
 
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:
  
 
It sets the color of subsequent ''draw'' and ''fill'' operations.
 
It sets the color of subsequent ''draw'' and ''fill'' operations.
 +
  
 
{{Since|3.0}}
 
{{Since|3.0}}
Line 18: Line 19:
 
| <u><center>blue</center></u> || number || A number from 0 to 255 representing the "amount" of blue in the color
 
| <u><center>blue</center></u> || number || A number from 0 to 255 representing the "amount" of blue in the color
 
|}
 
|}
 +
 +
NB : You can also use hexadecimal numbers instead of decimal ones for each of the arguments.<br />
 +
For example : '''gc:setColorRGB(0xFF,0xA5,0x9D)''' is perfecly valid.<br />
  
 
== Example  ==
 
== Example  ==

Latest revision as of 11:27, 20 December 2011

gc:setColorRGB is a function that is part of the gc (Graphics Context).

It sets the color of subsequent draw and fill operations.


This has been introduced in TI-Nspire OS 3.0 (Changes).


Syntax

gc:setColorRGB(red, green, blue)

Parameter Type Description
red
number A number from 0 to 255 representing the "amount" of red in the color
green
number A number from 0 to 255 representing the "amount" of green in the color
blue
number A number from 0 to 255 representing the "amount" of blue in the color

NB : You can also use hexadecimal numbers instead of decimal ones for each of the arguments.
For example : gc:setColorRGB(0xFF,0xA5,0x9D) is perfecly valid.

Example

function on.paint(gc)
   gc:setColorRGB(0,0,0)
   gc:drawString("Hello you",0,0,"top") -- will display that text in black

   gc:setColorRGB(255,0,0)
   gc:drawString("Hello you too",20,20,"top") -- will display that text in red
end