Class representing a color, based on Int. Provides a variety of methods for creating and converting colors.
FlxColors can be written as Ints. This means you can pass a hex value such as 0xff123456 to a function expecting a FlxColor, and it will automatically become a FlxColor "object". Similarly, FlxColors may be treated as Ints.
Note that when using properties of a FlxColor other than ARGB, the values are ultimately stored as ARGB values, so repeatedly manipulating HSB/HSL/CMYK values may result in a gradual loss of precision.
Static variables
staticread onlycolorLookup:Map<String, Int> = FlxMacroUtil.buildMap("flixel.util.FlxColor")
Static methods
staticinlinefromCMYK(Cyan:Float, Magenta:Float, Yellow:Float, Black:Float, Alpha:Float = 1):FlxColor
Generate a color from CMYK values (0 to 1)
Parameters:
Cyan | The cyan value of the color from 0 to 1 |
---|---|
Magenta | The magenta value of the color from 0 to 1 |
Yellow | The yellow value of the color from 0 to 1 |
Black | The black value of the color from 0 to 1 |
Alpha | How opaque the color should be, from 0 to 1 |
Returns:
The color as a FlxColor
staticfromHSB(Hue:Float, Saturation:Float, Brightness:Float, Alpha:Float = 1):FlxColor
Generate a color from HSB (aka HSV) components.
Parameters:
Hue | A number between 0 and 360, indicating position on a color strip or wheel. |
---|---|
Saturation | A number between 0 and 1, indicating how colorful or gray the color should be. 0 is gray, 1 is vibrant. |
Brightness | (aka Value) A number between 0 and 1, indicating how bright the color should be. 0 is black, 1 is full bright. |
Alpha | How opaque the color should be, either between 0 and 1 or 0 and 255. |
Returns:
The color as a FlxColor
staticinlinefromHSL(Hue:Float, Saturation:Float, Lightness:Float, Alpha:Float = 1):FlxColor
Generate a color from HSL components.
Parameters:
Hue | A number between 0 and 360, indicating position on a color strip or wheel. |
---|---|
Saturation | A number between 0 and 1, indicating how colorful or gray the color should be. 0 is gray, 1 is vibrant. |
Lightness | A number between 0 and 1, indicating the lightness of the color |
Alpha | How opaque the color should be, either between 0 and 1 or 0 and 255. |
Returns:
The color as a FlxColor
staticinlinefromInt(Value:Int):FlxColor
Create a color from the least significant four bytes of an Int
Parameters:
Value | And Int with bytes in the format 0xAARRGGBB |
---|
Returns:
The color as a FlxColor
staticinlinefromRGB(Red:Int, Green:Int, Blue:Int, Alpha:Int = 255):FlxColor
Generate a color from integer RGB values (0 to 255)
Parameters:
Red | The red value of the color from 0 to 255 |
---|---|
Green | The green value of the color from 0 to 255 |
Blue | The green value of the color from 0 to 255 |
Alpha | How opaque the color should be, from 0 to 255 |
Returns:
The color as a FlxColor
staticinlinefromRGBFloat(Red:Float, Green:Float, Blue:Float, Alpha:Float = 1):FlxColor
Generate a color from float RGB values (0 to 1)
Parameters:
Red | The red value of the color from 0 to 1 |
---|---|
Green | The green value of the color from 0 to 1 |
Blue | The green value of the color from 0 to 1 |
Alpha | How opaque the color should be, from 0 to 1 |
Returns:
The color as a FlxColor
staticfromString(str:String):Null<FlxColor>
staticinlinegetAnalogousHarmony(this:Int, Threshold:Int = 30):Harmony
Returns an Analogous Color Harmony for the given color. An Analogous harmony are hues adjacent to each other on the color wheel
Parameters:
Threshold | Control how adjacent the colors will be (default +- 30 degrees) |
---|
Returns:
Object containing 3 properties: original (the original color), warmer (the warmer analogous color) and colder (the colder analogous color)
staticgetColorInfo(this:Int):String
Get a string of color information about this color
Returns:
A string containing information about this color
staticinlinegetComplementHarmony(this:Int):FlxColor
Returns a Complementary Color Harmony of this color. A complementary hue is one directly opposite the color given on the color wheel
Returns:
The complimentary color
staticgetDarkened(this:Int, Factor:Float = 0.2):FlxColor
Get a darkened version of this color
Parameters:
Factor | Value from 0 to 1 of how much to progress toward black. |
---|
Returns:
A darkened version of this color
staticgetHSBColorWheel(Alpha:Int = 255):Array<FlxColor>
Get HSB color wheel values in an array which will be 360 elements in size
Parameters:
Alpha | Alpha value for each color of the color wheel, between 0 (transparent) and 255 (opaque) |
---|
Returns:
HSB color wheel as Array of FlxColors
staticinlinegetInverted(this:Int):FlxColor
Get the inversion of this color
Returns:
The inversion of this color
staticinlinegetLightened(this:Int, Factor:Float = 0.2):FlxColor
Get a lightened version of this color
Parameters:
Factor | Value from 0 to 1 of how much to progress toward white. |
---|
Returns:
A lightened version of this color
staticinlinegetSplitComplementHarmony(this:Int, Threshold:Int = 30):Harmony
Returns an Split Complement Color Harmony for this color. A Split Complement harmony are the two hues on either side of the color's Complement
Parameters:
Threshold | Control how adjacent the colors will be to the Complement (default +- 30 degrees) |
---|
Returns:
Object containing 3 properties: original (the original color), warmer (the warmer analogous color) and colder (the colder analogous color)
staticinlinegetTriadicHarmony(this:Int):TriadicHarmony
Returns a Triadic Color Harmony for this color. A Triadic harmony are 3 hues equidistant from each other on the color wheel.
Returns:
Object containing 3 properties: color1 (the original color), color2 and color3 (the equidistant colors)
staticgradient(Color1:FlxColor, Color2:FlxColor, Steps:Int, ?Ease:Float ‑> Float):Array<FlxColor>
Create a gradient from one color to another
Parameters:
Color1 | The color to shift from |
---|---|
Color2 | The color to shift to |
Steps | How many colors the gradient should have |
Ease | An optional easing function, such as those provided in FlxEase |
Returns:
An array of colors of length Steps, shifting from Color1 to Color2
staticinlineinterpolate(Color1:FlxColor, Color2:FlxColor, Factor:Float = 0.5):FlxColor
Get an interpolated color based on two different colors.
Parameters:
Color1 | The first color |
---|---|
Color2 | The second color |
Factor | Value from 0 to 1 representing how much to shift Color1 toward Color2 |
Returns:
The interpolated color
staticinlinesetCMYK(this:Int, Cyan:Float, Magenta:Float, Yellow:Float, Black:Float, Alpha:Float = 1):FlxColor
Set CMYK values as floats (0 to 1)
Parameters:
Cyan | The cyan value of the color from 0 to 1 |
---|---|
Magenta | The magenta value of the color from 0 to 1 |
Yellow | The yellow value of the color from 0 to 1 |
Black | The black value of the color from 0 to 1 |
Alpha | How opaque the color should be, from 0 to 1 |
Returns:
This color
staticinlinesetHSB(this:Int, Hue:Float, Saturation:Float, Brightness:Float, Alpha:Float):FlxColor
Set HSB (aka HSV) components
Parameters:
Hue | A number between 0 and 360, indicating position on a color strip or wheel. |
---|---|
Saturation | A number between 0 and 1, indicating how colorful or gray the color should be. 0 is gray, 1 is vibrant. |
Brightness | (aka Value) A number between 0 and 1, indicating how bright the color should be. 0 is black, 1 is full bright. |
Alpha | How opaque the color should be, either between 0 and 1 or 0 and 255. |
Returns:
This color
staticinlinesetHSL(this:Int, Hue:Float, Saturation:Float, Lightness:Float, Alpha:Float):FlxColor
Set HSL components.
Parameters:
Hue | A number between 0 and 360, indicating position on a color strip or wheel. |
---|---|
Saturation | A number between 0 and 1, indicating how colorful or gray the color should be. 0 is gray, 1 is vibrant. |
Lightness | A number between 0 and 1, indicating the lightness of the color |
Alpha | How opaque the color should be, either between 0 and 1 or 0 and 255 |
Returns:
This color
staticinlinesetRGB(this:Int, Red:Int, Green:Int, Blue:Int, Alpha:Int = 255):FlxColor
Set RGB values as integers (0 to 255)
Parameters:
Red | The red value of the color from 0 to 255 |
---|---|
Green | The green value of the color from 0 to 255 |
Blue | The green value of the color from 0 to 255 |
Alpha | How opaque the color should be, from 0 to 255 |
Returns:
This color
staticinlinesetRGBFloat(this:Int, Red:Float, Green:Float, Blue:Float, Alpha:Float = 1):FlxColor
Set RGB values as floats (0 to 1)
Parameters:
Red | The red value of the color from 0 to 1 |
---|---|
Green | The green value of the color from 0 to 1 |
Blue | The green value of the color from 0 to 1 |
Alpha | How opaque the color should be, from 0 to 1 |
Returns:
This color
staticinlinesubtract(lhs:FlxColor, rhs:FlxColor):FlxColor
Subtract the RGB channels of one FlxColor from another
staticinlineto24Bit(this:Int):FlxColor
Return a 24 bit version of this color (i.e. without an alpha value)
Returns:
A 24 bit version of this color
staticinlinetoHexString(this:Int, Alpha:Bool = true, Prefix:Bool = true):String
Return a String representation of the color in the format
Parameters:
Alpha | Whether to include the alpha value in the hex string |
---|---|
Prefix | Whether to include "0x" prefix at start of string |
Returns:
A string of length 10 in the format 0xAARRGGBB
staticinlinetoWebString(this:Int):String
Return a String representation of the color in the format #RRGGBB
Returns:
A string of length 7 in the format #RRGGBB