Click or drag to resize

Color Structure

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 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 Color8(Byte, Byte, Byte, Byte) and the `r8`/`g8`/`b8`/`a8` properties.

Namespace:  Godot
Assembly:  GodotSharp (in GodotSharp.dll) Version: 1.0.0
Syntax
C#
[SerializableAttribute]
public struct Color : IEquatable<Color>

The Color type exposes the following members.

Constructors
  NameDescription
Public methodColor(Int32)
Constructs a color from a 32-bit integer in RGBA format (each byte represents a color channel).
Public methodColor(Int64)
Constructs a color from a 64-bit integer in RGBA format (each word represents a color channel).
Public methodColor(String)
Constructs a color from the HTML hexadecimal color string in RGBA format.
Public methodColor(Color, Single)
Constructs a color from an existing color and an alpha value.
Public methodColor(Single, Single, Single, Single)
Constructs a color from RGBA values, typically on the range of 0 to 1.
Top
Properties
  NameDescription
Public propertya8
Wrapper for a that uses the range 0 to 255 instead of 0 to 1.
Public propertyb8
Wrapper for b that uses the range 0 to 255 instead of 0 to 1.
Public propertyg8
Wrapper for g that uses the range 0 to 255 instead of 0 to 1.
Public propertyh
The HSV hue of this color, on the range 0 to 1.
Public propertyItem
Access color components using their index.
Public propertyr8
Wrapper for r that uses the range 0 to 255 instead of 0 to 1.
Public propertys
The HSV saturation of this color, on the range 0 to 1.
Public propertyv
The HSV value (brightness) of this color, on the range 0 to 1.
Top
Methods
  NameDescription
Public methodBlend
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.
Public methodStatic memberColor8
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.
Public methodStatic memberColorN
Returns a color according to the standardized name, with the specified alpha value. Supported color names are the same as the constants defined in Colors.
Public methodContrasted
Returns the most contrasting color.
Public methodDarkened
Returns a new color resulting from making this color darker by the specified ratio (on the range of 0 to 1).
Public methodEquals(Object) (Overrides ValueTypeEquals(Object).)
Public methodEquals(Color)
Public methodStatic memberFromHsv
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.
Public methodGetHashCode (Overrides ValueTypeGetHashCode.)
Public methodGetType (Inherited from Object.)
Public methodInverted
Returns the inverted color: `(1 - r, 1 - g, 1 - b, a)`.
Public methodIsEqualApprox
Returns true if this color and `other` are approximately equal, by running IsEqualApprox(Single, Single) on each component.
Public methodLightened
Returns a new color resulting from making this color lighter by the specified ratio (on the range of 0 to 1).
Public methodLinearInterpolate(Color, Color)
Returns the result of the linear interpolation between this color and `to` by color amount `weight`.
Public methodLinearInterpolate(Color, Single)
Returns the result of the linear interpolation between this color and `to` by amount `weight`.
Public methodToAbgr32
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.
Public methodToAbgr64
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.
Public methodToArgb32
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.
Public methodToArgb64
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.
Public methodToHsv
Converts a color to HSV values. This is equivalent to using each of the `h`/`s`/`v` properties, but much more efficient.
Public methodToHtml
Returns the color's HTML hexadecimal color string in RGBA format.
Public methodToRgba32
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.
Public methodToRgba64
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.
Public methodToString (Overrides ValueTypeToString.)
Public methodToString(String)
Top
Operators
Fields
  NameDescription
Public fielda
The color's alpha (transparency) component, typically on the range of 0 to 1.
Public fieldb
The color's blue component, typically on the range of 0 to 1.
Public fieldg
The color's green component, typically on the range of 0 to 1.
Public fieldr
The color's red component, typically on the range of 0 to 1.
Top
See Also