Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
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 C#과 GDScript의 API 차이점 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 |
|
get_luminance ( ) const |
|
html_is_valid ( String color ) static |
|
inverted ( ) const |
|
is_equal_approx ( Color to ) const |
|
linear_to_srgb ( ) const |
|
srgb_to_linear ( ) const |
|
to_abgr32 ( ) const |
|
to_abgr64 ( ) const |
|
to_argb32 ( ) const |
|
to_argb64 ( ) const |
|
to_rgba32 ( ) const |
|
to_rgba64 ( ) const |
Operators¶
operator != ( Color right ) |
|
operator * ( Color right ) |
|
operator * ( float right ) |
|
operator * ( int right ) |
|
operator + ( Color right ) |
|
operator - ( Color right ) |
|
operator / ( Color right ) |
|
operator / ( float right ) |
|
operator / ( int right ) |
|
operator == ( Color right ) |
|
operator [] ( int index ) |
|
operator unary+ ( ) |
|
operator unary- ( ) |
Constants¶
ALICE_BLUE = Color(0.941176, 0.972549, 1, 1)
Alice blue color.
ANTIQUE_WHITE = Color(0.980392, 0.921569, 0.843137, 1)
Antique white color.
AQUA = Color(0, 1, 1, 1)
Aqua color.
AQUAMARINE = Color(0.498039, 1, 0.831373, 1)
Aquamarine color.
AZURE = Color(0.941176, 1, 1, 1)
Azure color.
BEIGE = Color(0.960784, 0.960784, 0.862745, 1)
Beige color.
BISQUE = Color(1, 0.894118, 0.768627, 1)
Bisque color.
BLACK = Color(0, 0, 0, 1)
Black color. In GDScript, this is the default value of any color.
BLANCHED_ALMOND = Color(1, 0.921569, 0.803922, 1)
Blanched almond color.
BLUE = Color(0, 0, 1, 1)
Blue color.
BLUE_VIOLET = Color(0.541176, 0.168627, 0.886275, 1)
Blue violet color.
BROWN = Color(0.647059, 0.164706, 0.164706, 1)
Brown color.
BURLYWOOD = Color(0.870588, 0.721569, 0.529412, 1)
Burlywood color.
CADET_BLUE