Grayscale color (0)

, under actionscript.

My first post 😀 Just testing the syntax highlighting too. It works perfect!

This is how I create a grayscale color in actionscript 3.
[as]
grayscale ( 140 );
[/as]
The function:
[as]/*
* Get a grayscale color from a tint
*
* @param tint Enter tint from range 0 to 255
* @return Gray hexadecimal colorvalue
* @tiptext
*/
public static function grayscale ( tint:uint = 0 ):uint
{
// restriction
if (tint < 0) { tint = 0 }
if (tint > 255) { tint = 255 }
// return calculation of color
return (tint << 16) | (tint << 8) | tint;
}[/as]

Feel free to add comment

Say something interesting

Please link to code from an external resource, like gist.github.com.