Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
Color¶
A color represented in RGBA format.
Description¶
A color represented in RGBA format by a red (r), green (g), blue (b), and alpha (a) component. Each component is a 16-bit floating-point value, usually ranging from 0.0
to 1.0
. Some properties (such as CanvasItem.modulate) may support values greater than 1.0
, for overbright or HDR (High Dynamic Range) colors.
Colors can be created in various ways: By the various Color constructors, by static methods such as from_hsv, and by using a name from the set of standardized colors based on X11 color names with the addition of TRANSPARENT. GDScript also provides @GDScript.Color8, which uses integers from 0
to 255
and doesn't support overbright colors.
Note: In a boolean context, a Color will evaluate to false
if it is equal to Color(0, 0, 0, 1)
(opaque black). Otherwise, a Color will always evaluate to true
.
Примітка
There are notable differences when using this API with C#. See Відмінності API C# в GDScript for more information.
Tutorials¶
Properties¶
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Constructors¶
Color ( ) |
|
Methods¶
clamp ( Color min=Color(0, 0, 0, 0), Color max=Color(1, 1, 1, 1) ) const |
|
from_hsv ( float h, float s, float v, float alpha=1.0 ) static |
|
from_ok_hsl ( float h, float s, float l, float alpha=1.0 ) static |
|
from_rgbe9995 ( int rgbe ) static |
|
from_string ( String str, Color default ) static |