Color in RGBA format with some support for ARGB format.
    public struct Color : IEquatable<Color>

A color is represented as red, green and blue (r,g,b) components. Additionally, “a” represents the alpha component, often used for transparency. Values are in floating point and usually range from 0 to 1. Some methods (such as set_modulate(color)) may accept values > 1.

You can also create a color from standardised color names with [method @GDScript.ColorN].

Inheritance Chain


Static Methods

    public static Color Color8(byte r8, byte g8, byte b8, byte a8)

    public static Color FromHsv(float hue, float saturation, float value, float alpha = 1f)

    public static void ToHsv(Color color, out float hue, out float saturation, out float value)


    public Color(float r, float g, float b, float a = 1f)

Constructs a color from an RGBA profile using values between 0 and 1 (float).


var c = Color(0.2, 1.0, .7, .8) # a color of an RGBA(51, 255, 178, 204)


    public Color(int rgba)

Constructs a color from a 32-bit integer (each byte represents a component of the RGBA profile).


var c = Color(274) # a color of an RGBA(0, 0, 1, 18)


    public Color(string rgba)

Constructs a color from an HTML hexadecimal color string in ARGB or RGB format. See also [method @GDScript.ColorN].

The following string formats are supported:

"#ff00ff00" - ARGB format with ‘#’

"ff00ff00" - ARGB format

"#ff00ff" - RGB format with ‘#’

"ff00ff" - RGB format


The following code creates the same color of an RGBA(178, 217, 10, 255)

var c1 = Color(“#ffb2d90a”) # ARGB format with ‘#’

var c2 = Color(“ffb2d90a”) # ARGB format

var c3 = Color(“#b2d90a”) # RGB format with ‘#’

var c4 = Color(“b2d90a”) # RGB format


    public Color()


    public Single a

Alpha (0 to 1)

    public Single b

Blue (0 to 1)

    public Single g

Green (0 to 1)

    public Single r

Red (0 to 1)


    public int a8 { get; }

Alpha (0 to 255)

    public int b8 { get; }

Blue (0 to 255)

    public  Black { get; }

    public int g8 { get; }

Green (0 to 255)

    public float h { get; set; }

Hue (0 to 1)

    public int r8 { get; }

Red (0 to 255)

    public float s { get; set; }

Saturation (0 to 1)

    public float this[] { get; set; }

    public float v { get; set; }

Value (0 to 1)


    public Color Blend(Color over)

Returns a new color resulting from blending this color over another color. If the color is opaque, the result would also be opaque. The other color could then take a range of values with different alpha values.


var bg = Color(0.0, 1.0, 0.0, 0.5) # Green with alpha of 50%

var fg = Color(1.0, 0.0, 0.0, .5) # Red with alpha of 50%

var blendedColor = bg.blend(fg) # Brown with alpha of 75%


    public Color Contrasted()

Returns the most contrasting color.


var c = Color(.3, .4, .9)

var contrastedColor = c.contrasted() # a color of an RGBA(204, 229, 102, 255)


    public override bool Equals(object obj)

    public bool Equals(Color other)

    public override int GetHashCode()

    public float Gray()

Returns the color’s grayscale.

The gray is calculated by (r + g + b) / 3.


var c = Color(0.2, 0.45, 0.82)

var gray = c.gray() # a value of 0.466667


    public Color Inverted()

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


var c = Color(.3, .4, .9)

var invertedColor = c.inverted() # a color of an RGBA(178, 153, 26, 255)


    public Color LinearInterpolate(Color b, float t)

Returns the color of the linear interpolation with another color. The value t is between 0 and 1 (float).


var c1 = Color(1.0, 0.0, 0.0)

var c2 = Color(0.0, 1.0, 0.0)

var li_c = c1.linear_interpolate(c2, 0.5) # a color of an RGBA(128, 128, 0, 255)


    public int To32()

    public int ToArgb32()

Returns the color’s 32-bit integer in ARGB format (each byte represents a component of the ARGB profile). More compatible with DirectX.


var c = Color(1, .5, .2)

print(str(c.to_32())) # prints 4294934323


    public string ToHtml(bool include_alpha = true)

Returns the color’s HTML hexadecimal color string in ARGB format (ex: ff34f822).

Optionally flag ‘false’ to not include alpha in hexadecimal string.


var c = Color(1, 1, 1, .5)

var s1 = c.to_html() # Results “7fffffff”

var s2 = c.to_html(false) # Results ‘ffffff’


    public override string ToString()

    public string ToString(string format)


    public static bool operator ==(Color left, Color right)

    public static bool operator >(Color left, Color right)

    public static bool operator !=(Color left, Color right)

    public static bool operator <(Color left, Color right)