Package | starling.utils |
Class | public class Color |
Inheritance | Color Object |
The HSL and HSV calculations conform to theory and implementation found on Wikipedia and rapidtables.com.
Method | Defined By | ||
---|---|---|---|
argb(alpha:int, red:int, green:int, blue:int):uint [static] Creates an ARGB color, stored in an unsigned integer. | Color | ||
getAlpha(color:uint):int [static] Returns the alpha part of an ARGB color (0 - 255). | Color | ||
getBlue(color:uint):int [static] Returns the blue part of an (A)RGB color (0 - 255). | Color | ||
getGreen(color:uint):int [static] Returns the green part of an (A)RGB color (0 - 255). | Color | ||
getRed(color:uint):int [static] Returns the red part of an (A)RGB color (0 - 255). | Color | ||
hsl(hue:Number, saturation:Number, lightness:Number):uint [static] Creates an RGB color from hue, saturation and lightness. | Color | ||
hsv(hue:Number, saturation:Number, value:Number):uint [static] Creates an RGB color from hue, saturation and value (brightness). | Color | ||
interpolate(startColor:uint, endColor:uint, ratio:Number):uint [static] Calculates a smooth transition between one color to the next. | Color | ||
multiply(color:uint, factor:Number):uint [static] Multiplies all channels of an (A)RGB color with a certain factor. | Color | ||
rgb(red:int, green:int, blue:int):uint [static] Creates an RGB color, stored in an unsigned integer. | Color | ||
rgbToHsl(rgb:uint, hsl:Vector.<Number> = null):Vector.<Number> [static] Converts an RGB color into a vector with HSV components. | Color | ||
rgbToHsv(rgb:uint, hsv:Vector.<Number> = null):Vector.<Number> [static] Converts an RGB color into a vector with HSV components. | Color | ||
setAlpha(color:uint, alpha:int):uint [static] Sets the alpha part of an ARGB color (0 - 255). | Color | ||
setBlue(color:uint, blue:int):uint [static] Sets the blue part of an (A)RGB color (0 - 255). | Color | ||
setGreen(color:uint, green:int):uint [static] Sets the green part of an (A)RGB color (0 - 255). | Color | ||
setRed(color:uint, red:int):uint [static] Sets the red part of an (A)RGB color (0 - 255). | Color | ||
toVector(color:uint, out:Vector.<Number> = null):Vector.<Number> [static] Converts a color to a vector containing the RGBA components (in this order) scaled
between 0 and 1. | Color |
Constant | Defined By | ||
---|---|---|---|
AQUA : uint = 0x00ffff [static] | Color | ||
BLACK : uint = 0x000000 [static] | Color | ||
BLUE : uint = 0x0000ff [static] | Color | ||
FUCHSIA : uint = 0xff00ff [static] | Color | ||
GRAY : uint = 0x808080 [static] | Color | ||
GREEN : uint = 0x008000 [static] | Color | ||
LIME : uint = 0x00ff00 [static] | Color | ||
MAROON : uint = 0x800000 [static] | Color | ||
NAVY : uint = 0x000080 [static] | Color | ||
OLIVE : uint = 0x808000 [static] | Color | ||
PURPLE : uint = 0x800080 [static] | Color | ||
RED : uint = 0xff0000 [static] | Color | ||
SILVER : uint = 0xc0c0c0 [static] | Color | ||
TEAL : uint = 0x008080 [static] | Color | ||
WHITE : uint = 0xffffff [static] | Color | ||
YELLOW : uint = 0xffff00 [static] | Color |
argb | () | method |
public static function argb(alpha:int, red:int, green:int, blue:int):uint
Creates an ARGB color, stored in an unsigned integer. Channels are expected in the range 0 - 255.
Parameters
alpha:int | |
red:int | |
green:int | |
blue:int |
uint |
getAlpha | () | method |
public static function getAlpha(color:uint):int
Returns the alpha part of an ARGB color (0 - 255).
Parameters
color:uint |
int |
getBlue | () | method |
public static function getBlue(color:uint):int
Returns the blue part of an (A)RGB color (0 - 255).
Parameters
color:uint |
int |
getGreen | () | method |
public static function getGreen(color:uint):int
Returns the green part of an (A)RGB color (0 - 255).
Parameters
color:uint |
int |
getRed | () | method |
public static function getRed(color:uint):int
Returns the red part of an (A)RGB color (0 - 255).
Parameters
color:uint |
int |
hsl | () | method |
public static function hsl(hue:Number, saturation:Number, lightness:Number):uint
Creates an RGB color from hue, saturation and lightness. Assumes hue, saturation, and lightness are contained in the range [0, 1].
Parameters
hue:Number | |
saturation:Number | |
lightness:Number |
uint |
hsv | () | method |
public static function hsv(hue:Number, saturation:Number, value:Number):uint
Creates an RGB color from hue, saturation and value (brightness). Assumes hue, saturation, and value are contained in the range [0, 1].
Parameters
hue:Number | |
saturation:Number | |
value:Number |
uint |
interpolate | () | method |
public static function interpolate(startColor:uint, endColor:uint, ratio:Number):uint
Calculates a smooth transition between one color to the next.
ratio
is expected between 0 and 1.
Parameters
startColor:uint | |
endColor:uint | |
ratio:Number |
uint |
multiply | () | method |
public static function multiply(color:uint, factor:Number):uint
Multiplies all channels of an (A)RGB color with a certain factor.
Parameters
color:uint | |
factor:Number |
uint |
rgb | () | method |
public static function rgb(red:int, green:int, blue:int):uint
Creates an RGB color, stored in an unsigned integer. Channels are expected in the range 0 - 255.
Parameters
red:int | |
green:int | |
blue:int |
uint |
rgbToHsl | () | method |
public static function rgbToHsl(rgb:uint, hsl:Vector.<Number> = null):Vector.<Number>
Converts an RGB color into a vector with HSV components.
Parameters
rgb:uint — the standard RGB color
| |
hsl:Vector.<Number> (default = null ) — a vector to be used for the result; passing null will create a new one.
|
Vector.<Number> — a vector containing hue, saturation, and lightness, in this order. Range: [0..1]
|
rgbToHsv | () | method |
public static function rgbToHsv(rgb:uint, hsv:Vector.<Number> = null):Vector.<Number>
Converts an RGB color into a vector with HSV components.
Parameters
rgb:uint — the standard RGB color
| |
hsv:Vector.<Number> (default = null ) — a vector to be used for the result; passing null will create a new one.
|
Vector.<Number> — a vector containing hue, saturation, and value, in this order. Range: [0..1]
|
setAlpha | () | method |
public static function setAlpha(color:uint, alpha:int):uint
Sets the alpha part of an ARGB color (0 - 255).
Parameters
color:uint | |
alpha:int |
uint |
setBlue | () | method |
public static function setBlue(color:uint, blue:int):uint
Sets the blue part of an (A)RGB color (0 - 255).
Parameters
color:uint | |
blue:int |
uint |
setGreen | () | method |
public static function setGreen(color:uint, green:int):uint
Sets the green part of an (A)RGB color (0 - 255).
Parameters
color:uint | |
green:int |
uint |
setRed | () | method |
public static function setRed(color:uint, red:int):uint
Sets the red part of an (A)RGB color (0 - 255).
Parameters
color:uint | |
red:int |
uint |
toVector | () | method |
public static function toVector(color:uint, out:Vector.<Number> = null):Vector.<Number>
Converts a color to a vector containing the RGBA components (in this order) scaled between 0 and 1.
Parameters
color:uint | |
out:Vector.<Number> (default = null )
|
Vector.<Number> |
AQUA | Constant |
public static const AQUA:uint = 0x00ffff
BLACK | Constant |
public static const BLACK:uint = 0x000000
BLUE | Constant |
public static const BLUE:uint = 0x0000ff
FUCHSIA | Constant |
public static const FUCHSIA:uint = 0xff00ff
GRAY | Constant |
public static const GRAY:uint = 0x808080
GREEN | Constant |
public static const GREEN:uint = 0x008000
LIME | Constant |
public static const LIME:uint = 0x00ff00
MAROON | Constant |
public static const MAROON:uint = 0x800000
NAVY | Constant |
public static const NAVY:uint = 0x000080
OLIVE | Constant |
public static const OLIVE:uint = 0x808000
PURPLE | Constant |
public static const PURPLE:uint = 0x800080
RED | Constant |
public static const RED:uint = 0xff0000
SILVER | Constant |
public static const SILVER:uint = 0xc0c0c0
TEAL | Constant |
public static const TEAL:uint = 0x008080
WHITE | Constant |
public static const WHITE:uint = 0xffffff
YELLOW | Constant |
public static const YELLOW:uint = 0xffff00