class flixel.util.FlxColorUtil

Available on all platforms

Class containing a set of functions for color manipulation and color harmony.

Class Fields

static function ARGBtoHexString(Color:Int):String

Return a String representation of the color in the format 0xAARRGGBB * *

Color

The color to get the String representation for *

returns

A string of length 10 characters in the format 0xAARRGGBB

static function ARGBtoRGB(Color:Int):Int

Turn a color with alpha and rgb values into a color without the alpha comoponent. * Example: 0x55ff0000 becomes 0xff0000 * *

Color

The Color to convert *

returns

The color without its alpha component

static function ARGBtoWebString(Color:Int):String

Return a String representation of the color in the format #RRGGBB * *

Color

The color to get the String representation for *

returns

A string of length 10 characters in the format 0xAARRGGBB

static function HSVtoARGB(H:Float, S:Float, V:Float, ?Alpha:Int = 255):Int

Convert a HSV (hue, saturation, lightness) color space value to an ARGB color * *

H

Hue degree, between 0 and 359 *

S

Saturation, between 0.0 (grey) and 1.0 *

V

Value, between 0.0 (black) and 1.0 *

Alpha

Alpha value to set per color (between 0 and 255) *

returns

32-bit ARGB color value (0xAARRGGBB)

static function RGBtoHSV(Color:Int):HSV

Convert an RGB color value to an object containing the HSV color space values: Hue, Saturation and Lightness * *

Color

The color in format 0xRRGGBB *

returns

Object with the properties hue (from 0 to 360), saturation (from 0 to 1.0) and lightness (from 0 to 1.0, also available under .value)

static function brighten(Color:Int, ?Factor:Float = 0.2f):Int

Lighten an ARGB color. * *

Color

Color in the format 0xAARRGGBB *

Factor

The higher, the lighter! Number from 0.0 to 1.0. *

returns

The lightened color

static function colorToHexString(Color:Int):String

Return a String containing a hex representation of the given color * *

Color

The color channel to get the hex value for, must be a value between 0 and 255) *

returns

A string of length 2 characters, i.e. 255 = FF, 0 = 00

static function darken(Color:Int, ?Factor:Float = 0.2f):Int

Darken an ARGB color. * *

Color

Color in the format 0xAARRGGBB *

Factor

The higher, the darker! Number from 0 to 1.0. *

returns

The darkened color

static function getARGB(Color:Int, ?Results:ARGB = null):ARGB

Loads an array with the ARGB values of a color. * RGB values are stored 0-255. Alpha is stored as a floating point number between 0 and 1 rounded to 4 decimals. * *

Color

The color you want to break into components. *

Results

An optional parameter, allows you to use an ARGB that already exists in memory to store the result. *

returns

An ARGB object containing the Red, Green, Blue and Alpha values of the given color.

static function getAlpha(Color:Int):Int

Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component, as a value between 0 and 255 * *

Color

In the format 0xAARRGGBB *

returns

The Alpha component of the color, will be between 0 and 255 (0 being no Alpha, 255 full Alpha)

static function getAlphaFloat(Color:Int):Float

Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component as a value between 0 and 1 * *

Color

In the format 0xAARRGGBB *

returns

The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent))

static function getAnalogousHarmony(Color: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 * Values returned in 0xAARRGGBB format with Alpha set to 255. * *

color

The color to base the harmony on *

threshold

Control how adjacent the colors will be (default +- 30 degrees) *

returns

Object containing 3 properties: color1 (the original color), color2 (the warmer analogous color) and color3 (the colder analogous color)

static function getBlue(Color:Int):Int

Given a native color value (in the format 0xAARRGGBB) this will return the Blue component, as a value between 0 and 255 * *

Color

In the format 0xAARRGGBB *

returns

The Blue component of the color, will be between 0 and 255 (0 being no color, 255 full Blue)

static function getColor24(Red:Int, Green:Int, Blue:Int):Int

Given 3 color values this will return an integer representation of it * *

Red

The Red channel value (between 0 and 255) *

Green

The Green channel value (between 0 and 255) *

Blue

The Blue channel value (between 0 and 255) *

returns

A native color value integer (format: 0xRRGGBB)

static function getColor32(Alpha:Int, Red:Int, Green:Int, Blue:Int):Int

Given an alpha and 3 color values this will return an integer representation of it (ARGB format) * *

Alpha

The Alpha value (between 0 and 255) *

Red

The Red channel value (between 0 and 255) *

Green

The Green channel value (between 0 and 255) *

Blue

The Blue channel value (between 0 and 255) *

returns

A native color value integer (format: 0xAARRGGBB)

static function getColorInfo(Color:Int):String

Returns a String containing handy information about the given color including String hex value, * RGB format information and HSL information. Each section starts on a newline, 3 lines in total. * *

Color

A color value in the format 0xAARRGGBB *

returns

String containing the 3 lines of information

static function getComplementHarmony(Color:Int):Int

Returns a Complementary Color Harmony for the given color. * A complementary hue is one directly opposite the color given on the color wheel * Value returned in 0xAARRGGBB format with Alpha set to 255. * *

Color

The color to base the harmony on *

returns

0xAARRGGBB format color value

static function getGreen(Color:Int):Int

Given a native color value (in the format 0xAARRGGBB) this will return the Green component, as a value between 0 and 255 * *

Color

In the format 0xAARRGGBB *

returns

The Green component of the color, will be between 0 and 255 (0 being no color, 255 full Green)

static function getHSBA(Color:Int, ?Results:HSBA = null):HSBA

Loads an array with the HSB values of a integer color. * Hue is a value between 0 and 360. Saturation, Brightness and Alpha * are as floating point numbers between 0 and 1 rounded to 4 decimals. * *

Color

The color you want to break into components. *

Results

An optional parameter, allows you to use an array that already exists in memory to store the result. *

returns

An HSBA object containing the Red, Green, Blue and Alpha values of the given color.

static function getHSVColorWheel(?Alpha:Int = 255):Array<Int>

Get HSV color wheel values in an array which will be 360 elements in size * *

Alpha

Alpha value for each color of the color wheel, between 0 (transparent) and 255 (opaque) *

returns

HSV color wheel as Array of Ints

static function getRandomColor(?Min:Int = 0, ?Max:Int = 255, ?Alpha:Int = 255):Int

Deprecated; please use FlxRandom.color() instead. * Returns a random color value between black and white * *

Min

The lowest value to use for each channel. *

Max

The highest value to use for each channel. *

Alpha

The alpha value of the returning color (default 255 = fully opaque). *

returns

A color value in hex ARGB format.

static function getRed(Color:Int):Int

Given a native color value (in the format 0xAARRGGBB) this will return the Red component, as a value between 0 and 255 * *

Color

In the format 0xAARRGGBB *

returns

The Red component of the color, will be between 0 and 255 (0 being no color, 255 full Red)

static function getSplitComplementHarmony(Color:Int, ?Threshold:Int = 30):Harmony

Returns an Split Complement Color Harmony for the given color. * A Split Complement harmony are the two hues on either side of the color's Complement * Values returned in 0xAARRGGBB format with Alpha set to 255. * *

Color

The color to base the harmony on *

Threshold

Control how adjacent the colors will be to the Complement (default +- 30 degrees) *

returns

Object containing 3 properties: color1 (the original color), color2 (the warmer analogous color) and color3 (the colder analogous color)

static function getTriadicHarmony(Color:Int):TriadicHarmony

Returns a Triadic Color Harmony for the given color. A Triadic harmony are 3 hues equidistant * from each other on the color wheel. Values returned in 0xAARRGGBB format with Alpha set to 255. * *

Color

The color to base the harmony on *

returns

Object containing 3 properties: color1 (the original color), color2 and color3 (the equidistant colors)

static function interpolateColor(Color1:Int, Color2:Int, Steps:Int, CurrentStep:Int, ?Alpha:Int = 255):Int

Get an interpolated color based on two different colors. * *

Color1

The first color *

Color2

The second color *

Steps

The amount of total steps *

CurrentStep

The step the interpolated color should be on *

Alpha

The alpha value you want the interpolated color to have *

returns

The interpolated color

static function interpolateColorWithRGB(Color:Int, R2:Int, G2:Int, B2:Int, Steps:Int, CurrentStep:Int):Int

Get an interpolated color based on a color and the RGB value of a second color. * *

Color

The first color *

R2

The red value of the second color *

G2

The green value of the second color *

B2

The blue value of the second color *

Steps

The amount of total steps *

CurrentStep

The step the interpolated color should be on *

Alpha

The alpha value you want the interpolated color to have *

returns

The interpolated color

static function interpolateRGB(R1:Int, G1:Int, B1:Int, R2:Int, G2:Int, B2:Int, Steps:Int, CurrentStep:Int):Int

Get an interpolated color based on the RGB values of two different colors. * *

R1

The red value of the first color *

G1

The green value of the first color *

B1

The blue value of the first color *

R2

The red value of the second color *

G2

The green value of the second color *

B2

The blue value of the second color *

Steps

The amount of total steps *

CurrentStep

The step the interpolated color should be on *

Alpha

The alpha value you want the interpolated color to have *

returns

The interpolated color

static function makeFromARGB(?Alpha:Float = 1.0f, Red:Int, Green:Int, Blue:Int):Int

Generate a color from ARGB components. * *

Alpha

How opaque the color should be, either between 0 and 1 or 0 and 255. *

Red

The red component, between 0 and 255. *

Green

The green component, between 0 and 255. *

Blue

The blue component, between 0 and 255. *

returns

The color as an integer

static function makeFromHSBA(Hue:Float, Saturation:Float, Brightness:Float, ?Alpha:Float = 1.0f):Int

Generate a color from HSBA components. * *

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

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 an integer