Legacy:Font/setColorMask: Difference between revisions

From Spherical
Jump to navigation Jump to search
created from http://web.archive.org/web/20110803192931/http://www.spheredev.org/wiki/Font.setColorMask
 
filled
 
Line 1: Line 1:
Set color masking for the font.
Set color masking for the font.


Line 6: Line 4:


==Usage==
==Usage==
{{Usage|returns={{{returns}}}|object=Font|func=setColorMask|params=color}}
{{Usage|object=Font|func=setColorMask|params=color}}


* '''param1''' type. param1 description
* '''color''' Sphere [[API:Color|Color]] object. The mask color
* '''param2''' type. param2 description
* '''paramN''' type. paramN description


==Examples==
==Examples==
(examples with syntaxhighlighted code)
The easiest way to take advantage of this function is to make/take a completely white font, and use colors in-game to control the color of the font.
<syntaxhighlight>
var font = GetSystemFont();
var red = CreateColor(255, 0, 0);
font.setColorMask(red);
font.drawText(0, 0, "Hello everynyun~!");
</syntaxhighlight>
 
The following is a simple demo of a line of text with a pulsating color:
<syntaxhighlight>
var font = GetSystemFont();
var direction = 1;
var greenness = 0;
 
SetFrameRate(60);
 
while (!IsAnyKeyPressed())
{
  greenness += direction;
  if (greenness > 255)
  {
    greenness = 255;
    direction = -1;
  }
  if (greenness < 0)
  {
    greenness = 0;
    direction = 1;
  }
 
  var col = CreateColor(0, greenness, 0);
  font.setColorMask(col);
  font.drawText("Press any key to quit...");
 
  FlipScreen();
}
</syntaxhighlight>


==Notes==
==Notes==
(notes)
* Once you set a mask color, it remains with the font until you change it. To reset the font's mask, use pure white (255, 255, 255) as the masking color.
* This function uses the filtering/shaping method of [[color masking]].
* If you wish to change and restore the mask color, use [[API:Font/getColorMask|Font.getColorMask]]().


==See also==
==See also==
* see also
* Sphere [[API:Font|Font]] object
* see also
* Sphere [[API:Color|Color]] object
* see also
* [[Color masking]]
* etc
* [[API:CreateColor|CreateColor]]()
* [[API:FlipScreen|FlipScreen]]()
* [[API:Font/drawText|Font.drawText]]()
* [[API:Font/getColorMask|Font.getColorMask]]()
* [[API:GetSystemFont|GetSystemFont]]()
* [[API:IsAnyKeyPressed|IsAnyKeyPressed]]()
* [[API:SetFrameRate|SetFrameRate]]()


{{API:Font/navbox}}
{{API:Font/navbox}}

Latest revision as of 23:32, 24 June 2013

Set color masking for the font.

Usage

Font.setColorMask(color);


  • color Sphere Color object. The mask color

Examples

The easiest way to take advantage of this function is to make/take a completely white font, and use colors in-game to control the color of the font.

var font = GetSystemFont();
var red = CreateColor(255, 0, 0);
font.setColorMask(red);
font.drawText(0, 0, "Hello everynyun~!");

The following is a simple demo of a line of text with a pulsating color:

var font = GetSystemFont();
var direction = 1;
var greenness = 0;

SetFrameRate(60);

while (!IsAnyKeyPressed())
{
  greenness += direction;
  if (greenness > 255)
  {
    greenness = 255;
    direction = -1;
  }
  if (greenness < 0)
  {
    greenness = 0;
    direction = 1;
  }
  
  var col = CreateColor(0, greenness, 0);
  font.setColorMask(col);
  font.drawText("Press any key to quit...");
  
  FlipScreen();
}

Notes

  • Once you set a mask color, it remains with the font until you change it. To reset the font's mask, use pure white (255, 255, 255) as the masking color.
  • This function uses the filtering/shaping method of color masking.
  • If you wish to change and restore the mask color, use Font.getColorMask().

See also

API:Font/navbox