A color represented by red, green, blue, and alpha (RGBA) components. The alpha component is often used for transparency. Values are in floating-point and usually range from 0 to 1. Some properties (such as godot.CanvasItem.modulate) may accept values greater than 1 (overbright or HDR colors).

If you want to supply values in a range of 0 to 255, you should use godot.Color.color8 and the r8/g8/b8/a8 properties.

Static methods

@:native("Color8")staticcolor8(r8:UInt8, g8:UInt8, b8:UInt8, ?a8:Null<UInt8>):Color

Returns a color constructed from integer red, green, blue, and alpha channels. Each channel should have 8 bits of information ranging from 0 to 255.

Parameters:

r8

The red component represented on the range of 0 to 255.

g8

The green component represented on the range of 0 to 255.

b8

The blue component represented on the range of 0 to 255.

a8

The alpha (transparency) component represented on the range of 0 to 255.

Returns:

The constructed color.

@:native("ColorN")staticcolorN(name:String, ?alpha:Single):Color

Returns a color according to the standardized name, with the specified alpha value. Supported color names are the same as the constants defined in godot.Colors.

Parameters:

name

The name of the color.

alpha

The alpha (transparency) component represented on the range of 0 to 1. Default: 1.

Returns:

The constructed color.

@:native("FromHsv")staticfromHsv(hue:Single, saturation:Single, value:Single, ?alpha:Single):Color

Constructs a color from an HSV profile, with values on the range of 0 to 1. This is equivalent to using each of the h/s/v properties, but much more efficient.

Parameters:

hue

The HSV hue, typically on the range of 0 to 1.

saturation

The HSV saturation, typically on the range of 0 to 1.

value

The HSV value (brightness), typically on the range of 0 to 1.

alpha

The alpha (transparency) value, typically on the range of 0 to 1.

Returns:

The constructed color.

@:op(A + B)staticinlineop_Addition(left:Color, right:Color):Color

Operator overload for godot.Color + godot.Color.

@:op(A / B)staticinlineop_Division(color:Color, scale:Float):Color

@:op(A / B)staticinlineop_Division(left:Color, right:Color):Color

Operator overload for godot.Color / ((global::System.Single)(Float)).

@:op(A == B)staticinlineop_Equality(left:Color, right:Color):Bool

Operator overload for godot.Color == godot.Color.

@:op(A > B)staticinlineop_GreaterThan(left:Color, right:Color):Bool

Operator overload for godot.Color > godot.Color.

@:op(A != B)staticinlineop_Inequality(left:Color, right:Color):Bool

Operator overload for godot.Color != godot.Color.

@:op(A < B)staticinlineop_LessThan(left:Color, right:Color):Bool

Operator overload for godot.Color < godot.Color.

@:op(A * B)staticinlineop_Multiply(color:Color, scale:Float):Color

@:op(A * B)staticinlineop_Multiply(left:Color, right:Color):Color

@:op(A * B)staticinlineop_Multiply(scale:Float, color:Color):Color

Operator overload for godot.Color * ((global::System.Single)(Float)).

@:op(A - B)staticinlineop_Subtraction(left:Color, right:Color):Color

Operator overload for godot.Color - godot.Color.

@:op(-A)staticinlineop_UnaryNegation(color:Color):Color

Operator overload for -godot.Color.

Constructor

@:native("new")new(r:Single, g:Single, b:Single, ?a:Single)

@:native("new")new(rgba:String)

@:native("new")new(rgba:Int64)

@:native("new")new(rgba:Int)

@:native("new")new(c:Color, ?a:Single)

Constructs a godot.Color from RGBA values, typically on the range of 0 to 1.

Parameters:

r

The color's red component, typically on the range of 0 to 1.

g

The color's green component, typically on the range of 0 to 1.

b

The color's blue component, typically on the range of 0 to 1.

a

The color's alpha (transparency) value, typically on the range of 0 to 1. Default: 1.

Variables

@:native("a")a:Single

The color's alpha (transparency) component, typically on the range of 0 to 1.

@:native("a8")a8:Int

Wrapper for godot.Color.a that uses the range 0 to 255 instead of 0 to 1.

Value: Getting is equivalent to multiplying by 255 and rounding. Setting is equivalent to dividing by 255.

@:native("b")b:Single

The color's blue component, typically on the range of 0 to 1.

@:native("b8")b8:Int

Wrapper for godot.Color.b that uses the range 0 to 255 instead of 0 to 1.

Value: Getting is equivalent to multiplying by 255 and rounding. Setting is equivalent to dividing by 255.

@:native("g")g:Single

The color's green component, typically on the range of 0 to 1.

@:native("g8")g8:Int

Wrapper for godot.Color.g that uses the range 0 to 255 instead of 0 to 1.

Value: Getting is equivalent to multiplying by 255 and rounding. Setting is equivalent to dividing by 255.

@:native("h")h:Single

The HSV hue of this color, on the range 0 to 1.

Value: Getting is a long process, refer to the source code for details. Setting uses godot.Color.fromHsv.

@:native("r")r:Single

The color's red component, typically on the range of 0 to 1.

@:native("r8")r8:Int

Wrapper for godot.Color.r that uses the range 0 to 255 instead of 0 to 1.

Value: Getting is equivalent to multiplying by 255 and rounding. Setting is equivalent to dividing by 255.

@:native("s")s:Single

The HSV saturation of this color, on the range 0 to 1.

Value: Getting is equivalent to the ratio between the min and max RGB value. Setting uses godot.Color.fromHsv.

@:native("v")v:Single

The HSV value (brightness) of this color, on the range 0 to 1.

Value: Getting is equivalent to using Math.max on the RGB components. Setting uses godot.Color.fromHsv.

Methods

@:native("Blend")blend(over:Color):Color

Returns a new color resulting from blending this color over another. If the color is opaque, the result is also opaque. The second color may have a range of alpha values.

Parameters:

over

The color to blend over.

Returns:

This color blended over over.

@:native("Contrasted")contrasted():Color

Returns the most contrasting color.

Returns:

The most contrasting color

@:native("Darkened")darkened(amount:Single):Color

Returns a new color resulting from making this color darker by the specified ratio (on the range of 0 to 1).

Parameters:

amount

The ratio to darken by.

Returns:

The darkened color.

@:native("Inverted")inverted():Color

Returns the inverted color: (1 - r, 1 - g, 1 - b, a).

Returns:

The inverted color.

@:native("IsEqualApprox")isEqualApprox(other:Color):Bool

Returns true if this color and other are approximately equal, by running godot.Mathf.isEqualApprox on each component.

Parameters:

other

The other color to compare.

Returns:

Whether or not the colors are approximately equal.

@:native("Lightened")lightened(amount:Single):Color

Returns a new color resulting from making this color lighter by the specified ratio (on the range of 0 to 1).

Parameters:

amount

The ratio to lighten by.

Returns:

The darkened color.

@:native("LinearInterpolate")linearInterpolate(to:Color, weight:Single):Color

@:native("LinearInterpolate")LinearInterpolate(to:Color, weight:Color):Color

Returns the result of the linear interpolation between this color and to by amount weight.

Parameters:

to

The destination color for interpolation.

weight

A value on the range of 0.0 to 1.0, representing the amount of interpolation.

Returns:

The resulting color of the interpolation.

@:native("ToAbgr32")toAbgr32():Int

Returns the color converted to a 32-bit integer in ABGR format (each byte represents a color channel). ABGR is the reversed version of the default format.

Returns:

A int representing this color in ABGR32 format.

@:native("ToAbgr64")toAbgr64():Int64

Returns the color converted to a 64-bit integer in ABGR format (each word represents a color channel). ABGR is the reversed version of the default format.

Returns:

A long representing this color in ABGR64 format.

@:native("ToArgb32")toArgb32():Int

Returns the color converted to a 32-bit integer in ARGB format (each byte represents a color channel). ARGB is more compatible with DirectX, but not used much in Godot.

Returns:

A int representing this color in ARGB32 format.

@:native("ToArgb64")toArgb64():Int64

Returns the color converted to a 64-bit integer in ARGB format (each word represents a color channel). ARGB is more compatible with DirectX, but not used much in Godot.

Returns:

A long representing this color in ARGB64 format.

@:native("ToHsv")toHsv(hue:Out<Single>, saturation:Out<Single>, value:Out<Single>):Void

Converts a color to HSV values. This is equivalent to using each of the h/s/v properties, but much more efficient.

Parameters:

hue

Output parameter for the HSV hue.

saturation

Output parameter for the HSV saturation.

value

Output parameter for the HSV value.

@:native("ToHtml")toHtml(?includeAlpha:Bool):String

Returns the color's HTML hexadecimal color string in RGBA format.

Parameters:

includeAlpha

Whether or not to include alpha. If false, the color is RGB instead of RGBA.

Returns:

A string for the HTML hexadecimal representation of this color.

@:native("ToRgba32")toRgba32():Int

Returns the color converted to a 32-bit integer in RGBA format (each byte represents a color channel). RGBA is Godot's default and recommended format.

Returns:

A int representing this color in RGBA32 format.

@:native("ToRgba64")toRgba64():Int64

Returns the color converted to a 64-bit integer in RGBA format (each word represents a color channel). RGBA is Godot's default and recommended format.

Returns:

A long representing this color in RGBA64 format.

@:native("ToString")toString():String

@:native("ToString")ToString(format:String):String

Converts this godot.Color to a string.

Returns:

A string representation of this color.