Difference between revisions of "Gb.display.setColor"

From Gamebuino Wiki
Jump to: navigation, search
(Created page with "{{lowercase}} __NOTOC__ == Description == Changes the color used to draw on the screen by all the display function. The colors can be either <code>WHITE</code> or <code>BLACK...")
 
(gray added)
 
(6 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
__NOTOC__
 
__NOTOC__
 
== Description ==
 
== Description ==
Changes the color used to draw on the screen by all the display function.
+
Changes the color used to draw on the screen by all the display functions.
  
The colors can be either <code>WHITE</code> or <code>BLACK</code> (actually these are just constants respectively equals to 0 and 1).
+
The colors can be either <code>WHITE</code>, <code>BLACK</code>, <code>GRAY</code> or <code>INVERT</code>.
  
 
Most of the display functions only have one color, the foreground color. But some functions also have a background color:
 
Most of the display functions only have one color, the foreground color. But some functions also have a background color:
Line 11: Line 11:
 
* [[gb.display.print]]
 
* [[gb.display.print]]
  
To have a transparent background, set the background the same color as the foreground.
+
INVERT color won't work with the drawCircle and fillCircle function, because the algorithm they use passes several times over the same pixel, so the color will toggle several times and be inconsistent.
  
 
== Syntax ==
 
== Syntax ==
<pre>gb.setColor(foregroundColor, backgroundColor);</pre>
+
<pre>gb.display.setColor(foregroundColor, backgroundColor);</pre>
  
 
== Parameters ==
 
== Parameters ==
* foregroundColor
+
* foregroundColor : <code>WHITE</code>, <code>BLACK</code>, <code>GRAY</code> or <code>INVERT</code>
* backgroundColor ''(optional)''
+
* backgroundColor ''(optional)'' : <code>WHITE</code>, <code>BLACK</code>, <code>GRAY</code> or <code>INVERT</code>. If no background color is specified, the background is transparent.
  
 
== Returns ==
 
== Returns ==
Line 24: Line 24:
  
 
== Example ==
 
== Example ==
 +
<gistit>https://github.com/Rodot/Gamebuino/blob/beta/libraries/Gamebuino/examples/5.Reference/display/color/color.ino</gistit>
  
 
== See also ==
 
== See also ==

Latest revision as of 2015-04-06T11:52:39

Description

Changes the color used to draw on the screen by all the display functions.

The colors can be either WHITE, BLACK, GRAY or INVERT.

Most of the display functions only have one color, the foreground color. But some functions also have a background color:

INVERT color won't work with the drawCircle and fillCircle function, because the algorithm they use passes several times over the same pixel, so the color will toggle several times and be inconsistent.

Syntax

gb.display.setColor(foregroundColor, backgroundColor);

Parameters

  • foregroundColor : WHITE, BLACK, GRAY or INVERT
  • backgroundColor (optional) : WHITE, BLACK, GRAY or INVERT. If no background color is specified, the background is transparent.

Returns

none

Example

See also