Struct Color
Representation of the RGBA color.
Assembly: FlaxEngine.dll
File: Engine/Core/Math/Color.h
Syntax
public struct Color
Constructors
Color()
Empty constructor.
Declaration
public Color() = default
Color(const Color& rgb, float a)
Initializes a new instance of the Color struct.
Declaration
public Color(const Color& rgb, float a)
Parameters
Color
rgb
The red, green and blue channels value. |
float
a
The alpha channel value. |
Color(const Color32& color)
Initializes a new instance of the Color struct.
Declaration
public Color(const Color32& color)
Parameters
Color32
color
The other color (32-bit RGBA). |
Color(const Float3& rgb, float a)
Initializes a new instance of the Color struct.
Declaration
public Color(const Float3& rgb, float a)
Parameters
Float3
rgb
The red, green and blue channels value. |
float
a
The alpha channel value. |
Color(const Float4& rgba)
Initializes a new instance of the Color struct.
Declaration
public Color(const Float4& rgba)
Parameters
Float4
rgba
The red, green, blue and alpha channels value. |
Color(float rgba)
Initializes a new instance of the Color struct.
Declaration
public Color(float rgba)
Parameters
float
rgba
The RGBA channels value. |
Fields
A
The alpha channel value.
Declaration
public float A
Field Value
float
|
AliceBlue
AntiqueWhite
Aqua
Aquamarine
Azure
B
The blue channel value.
Declaration
public float B
Field Value
float
|
Beige
Bisque
Black
BlanchedAlmond
Blue
BlueViolet
Brown
BurlyWood
CadetBlue
Chartreuse
Chocolate
Coral
CornflowerBlue
Cornsilk
Crimson
Cyan
DarkBlue
DarkCyan
DarkGoldenrod
DarkGray
DarkGreen
DarkKhaki
DarkMagenta
DarkOliveGreen
DarkOrange
DarkOrchid
DarkRed
DarkSalmon
DarkSeaGreen
DarkSlateBlue
DarkSlateGray
DarkTurquoise
DarkViolet
DeepPink
DeepSkyBlue
DimGray
DodgerBlue
Firebrick
FloralWhite
ForestGreen
Fuchsia
G
The green channel value.
Declaration
public float G
Field Value
float
|
Gainsboro
GhostWhite
Gold
Goldenrod
Gray
Green
GreenYellow
Honeydew
HotPink
IndianRed
Indigo
Ivory
Khaki
Lavender
LavenderBlush
LawnGreen
LemonChiffon
LightBlue
LightCoral
LightCyan
LightGoldenrodYellow
LightGray
LightGreen
LightPink
LightSalmon
LightSeaGreen
LightSkyBlue
LightSlateGray
LightSteelBlue
LightYellow
Lime
LimeGreen
Linen
Magenta
Maroon
MediumAquamarine
MediumBlue
MediumOrchid
MediumPurple
MediumSeaGreen
MediumSlateBlue
MediumSpringGreen
MediumTurquoise
MediumVioletRed
MidnightBlue
MintCream
MistyRose
Moccasin
NavajoWhite
Navy
OldLace
Olive
OliveDrab
Orange
OrangeRed
Orchid
PaleGoldenrod
PaleGreen
PaleTurquoise
PaleVioletRed
PapayaWhip
PeachPuff
Peru
Pink
Plum
PowderBlue
Purple
R
The red channel value.
Declaration
public float R
Field Value
float
|
Raw
The packed values into array floats.
Declaration
public float Raw[4]
Field Value
float
|
Red
RosyBrown
RoyalBlue
SaddleBrown
Salmon
SandyBrown
SeaGreen
SeaShell
Sienna
Silver
SkyBlue
SlateBlue
SlateGray
Snow
SpringGreen
SteelBlue
Tan
Teal
Thistle
Tomato
Transparent
Turquoise
Violet
Wheat
White
WhiteSmoke
Yellow
YellowGreen
Methods
AlphaMultiplied(float multiplier)
Returns the color with alpha channel multiplied by the given scale factor. The RGB channels remain the same.
Declaration
public Color AlphaMultiplied(float multiplier) const
Parameters
float
multiplier
The multiplier. |
Returns
Color
The modified color. |
Color(float r, float g, float b, float a=1)
Initializes a new instance of the Color struct.
Declaration
public Color(float r, float g, float b, float a=1)
Parameters
float
r
The red channel value. |
float
g
The green channel value. |
float
b
The blue channel value. |
float
a
The alpha channel value. |
Returns
FORCE_INLINE
|
FromARGB(uint32 argb)
Initializes from packed ARGB value (bottom bits contain Blue).
Declaration
public static Color FromARGB(uint32 argb)
Parameters
uint32
argb
The packed ARGB value (bottom bits contain Blue). |
Returns
Color
The color. |
FromBytes(byte r, byte g, byte b, byte a=255)
Initializes from values in range [0;255].
Declaration
public static Color FromBytes(byte r, byte g, byte b, byte a=255)
Parameters
byte
r
The red channel. |
byte
g
The green channel. |
byte
b
The blue channel. |
byte
a
The alpha channel. |
Returns
Color
The color. |
FromHex(const String& hex)
FromHex(const String& hex, bool& isValid)
Declaration
public static Color FromHex(const String& hex, bool& isValid)
Parameters
String
hex
|
bool
isValid
|
Returns
Color
|
FromHSV(const Float3& hsv, float alpha=1.0f)
Creates RGB color from Hue[0-360], Saturation[0-1] and Value[0-1] packed to XYZ vector.
Declaration
public static Color FromHSV(const Float3& hsv, float alpha=1.0f)
Parameters
Float3
hsv
The HSV color. |
float
alpha
The alpha value. Default is 1. |
Returns
Color
The RGB color. |
FromHSV(float hue, float saturation, float value, float alpha=1.0f)
Creates RGB color from Hue[0-360], Saturation[0-1] and Value[0-1].
Declaration
public static Color FromHSV(float hue, float saturation, float value, float alpha=1.0f)
Parameters
float
hue
The hue angle in degrees [0-360]. |
float
saturation
The saturation normalized [0-1]. |
float
value
The value normalized [0-1]. |
float
alpha
The alpha value. Default is 1. |
Returns
Color
The RGB color. |
FromRGB(uint32 rgb, float a=1.0f)
Initializes from packed RGB value (bottom bits contain Blue) of the color and separate alpha channel value.
Declaration
public static Color FromRGB(uint32 rgb, float a=1.0f)
Parameters
uint32
rgb
The packed RGB value (bottom bits contain Blue). |
float
a
The alpha channel. |
Returns
Color
The color. |
FromRGBA(uint32 rgba)
Initializes from packed RGBA value (bottom bits contain Alpha).
Declaration
public static Color FromRGBA(uint32 rgba)
Parameters
uint32
rgba
The packed RGBA value (bottom bits contain Alpha). |
Returns
Color
The color. |
GetHashCode()
Declaration
public uint32 GetHashCode() const
Returns
uint32
|
GetHashCode(const Color& v)
HasOpacity()
Declaration
public bool HasOpacity() const
Returns
bool
|
IsTransparent()
Declaration
public bool IsTransparent() const
Returns
bool
|
Lerp(const Color& start, const Color& end, float amount)
Performs a linear interpolation between two colors.
Declaration
public static Color Lerp(const Color& start, const Color& end, float amount)
Parameters
Color
start
The start color. |
Color
end
The end color. |
float
amount
The value between 0 and 1 indicating the weight of interpolation. |
Returns
Color
The linear interpolation of the two colors. |
Lerp(const Color& start, const Color& end, float amount, Color& result)
Performs a linear interpolation between two colors.
Declaration
public static void Lerp(const Color& start, const Color& end, float amount, Color& result)
Parameters
Color
start
The start color. |
Color
end
The end color. |
float
amount
The value between 0 and 1 indicating the weight of interpolation. |
Color
result
When the method completes, contains the linear interpolation of the two colors. |
LinearToSrgb(const Color& linear)
Declaration
public static Color LinearToSrgb(const Color& linear)
Parameters
Color
linear
|
Returns
Color
|
NearEqual(const Color& a, const Color& b)
Declaration
public static bool NearEqual(const Color& a, const Color& b)
Parameters
Color
a
|
Color
b
|
Returns
bool
|
NearEqual(const Color& a, const Color& b, float epsilon)
Declaration
public static bool NearEqual(const Color& a, const Color& b, float epsilon)
Parameters
Color
a
|
Color
b
|
float
epsilon
|
Returns
bool
|
operator!=(const Color& other)
operator-(const Color& b)
operator-(float b)
operator*(const Color& b)
operator*(float b)
operator*=(const Color& b)
operator*=(const float b)
operator/(float b)
operator+(const Color& b)
operator+(float b)
operator+=(const Color& b)
operator-=(const Color& b)
operator==(const Color& other)
Random()
Gets random color with opaque alpha.
Declaration
public static Color Random()
Returns
Color
The color. |
RGBMultiplied(Color multiplier)
Returns the color with RGB channels multiplied by the given color. The alpha channel remains the same.
Declaration
public Color RGBMultiplied(Color multiplier) const
Parameters
Color
multiplier
The multiplier. |
Returns
Color
The modified color. |
RGBMultiplied(float multiplier)
Returns the color with RGB channels multiplied by the given scale factor. The alpha channel remains the same.
Declaration
public Color RGBMultiplied(float multiplier) const
Parameters
float
multiplier
The multiplier. |
Returns
Color
The modified color. |
SrgbToLinear(const Color& srgb)
ToFloat3()
Declaration
public Float3 ToFloat3() const
Returns
Float3
|
ToFloat4()
Declaration
public Float4 ToFloat4() const
Returns
Float4
|
ToHexString()
ToHSV()
Gets Hue[0-360], Saturation[0-1] and Value[0-1] from RGB color.
Declaration
public Float3 ToHSV() const
Returns
Float3
HSV color |