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
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.
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.
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.
staticinlineop_Addition(left:Color, right:Color):Color
Operator overload for godot.Color
+ godot.Color
.
staticinlineop_Division(color:Color, scale:Float):Color
staticinlineop_Division(left:Color, right:Color):Color
Operator overload for godot.Color
/ ((global::System.Single)(Float
)).
staticinlineop_Equality(left:Color, right:Color):Bool
Operator overload for godot.Color
== godot.Color
.
staticinlineop_GreaterThan(left:Color, right:Color):Bool
Operator overload for godot.Color
> godot.Color
.
staticinlineop_Inequality(left:Color, right:Color):Bool
Operator overload for godot.Color
!= godot.Color
.
staticinlineop_LessThan(left:Color, right:Color):Bool
Operator overload for godot.Color
< godot.Color
.
staticinlineop_Multiply(color:Color, scale:Float):Color
staticinlineop_Multiply(left:Color, right:Color):Color
staticinlineop_Multiply(scale:Float, color:Color):Color
Operator overload for godot.Color
* ((global::System.Single)(Float
)).
staticinlineop_Subtraction(left:Color, right:Color):Color
Operator overload for godot.Color
- godot.Color
.
Constructor
new(r:Single, g:Single, b:Single, ?a:Single)
new(rgba:String)
new(rgba:Int64)
new(rgba:Int)
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
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.
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.
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.
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
.
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.
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
.
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
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
.
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.
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.
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.
linearInterpolate(to:Color, weight:Single):Color
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.
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.
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.
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.
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.
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. |
toHtml(?includeAlpha:Bool):String
Returns the color's HTML hexadecimal color string in RGBA format.
Parameters:
includeAlpha | Whether or not to include alpha. If |
---|
Returns:
A string for the HTML hexadecimal representation of this color.
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.
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.