Struct Color
- Namespace
- SimulationFramework
- Assembly
- SimulationFramework.dll
Represents a 32-bit RGBA color.
public readonly struct Color : IEquatable<Color>
- Implements
- Inherited Members
- Extension Methods
Constructors
Color()
Creates a new color.
public Color()
Color(byte, byte, byte)
Creates a new color with the provided RGB values, and an alpha of 255.
public Color(byte r, byte g, byte b)
Parameters
r
byteThe red component of the color.
g
byteThe green component of the color.
b
byteThe blue component of the color.
Color(byte, byte, byte, byte)
Creates a new color with the provided values.
public Color(byte r, byte g, byte b, byte a)
Parameters
r
byteThe red component of the color.
g
byteThe green component of the color.
b
byteThe blue component of the color.
a
byteThe alpha component of the color.
Color(Vector3)
Creates a new color from the provided RGB values.
public Color(Vector3 values)
Parameters
values
Vector3The RGB values of the color. The value of each component should be between 0 and 1.
Color(Vector4)
Creates a new color from the provided RGBA values.
public Color(Vector4 values)
Parameters
values
Vector4The RGBA values of the color. The value of each component should be between 0 and 1.
Color(float, float, float)
Creates a new color from the provided RGB values, and an alpha component of 255.
public Color(float r, float g, float b)
Parameters
r
floatThe red component of the color. This value should be between 0 and 1.
g
floatThe green component of the color. This value should be between 0 and 1.
b
floatThe blue component of the color. This value should be between 0 and 1.
Color(float, float, float, float)
Creates a new color from the provided RGBA values.
public Color(float r, float g, float b, float a)
Parameters
r
floatThe red component of the color. This value should be between 0 and 1.
g
floatThe green component of the color. This value should be between 0 and 1.
b
floatThe blue component of the color. This value should be between 0 and 1.
a
floatThe alpha component of the color. This value should be between 0 and 1.
Color(uint)
Creates a color from the provided uint RGBA value.
public Color(uint value)
Parameters
value
uintThe RGBA color value, where R is the least significant byte, and A is the most significant byte.
Fields
AliceBlue
An RGBA color with the value #F0F8FFFF.
public static readonly Color AliceBlue
Field Value
AntiqueWhite
An RGBA color with the value #FAEBD7FF.
public static readonly Color AntiqueWhite
Field Value
Aqua
An RGBA color with the value #00FFFFFF.
public static readonly Color Aqua
Field Value
Aquamarine
An RGBA color with the value #7FFFD4FF.
public static readonly Color Aquamarine
Field Value
Azure
An RGBA color with the value #F0FFFFFF.
public static readonly Color Azure
Field Value
Beige
An RGBA color with the value #F5F5DCFF.
public static readonly Color Beige
Field Value
Bisque
An RGBA color with the value #FFE4C4FF.
public static readonly Color Bisque
Field Value
Black
An RGBA color with the value #000000FF.
public static readonly Color Black
Field Value
BlanchedAlmond
An RGBA color with the value #FFEBCDFF.
public static readonly Color BlanchedAlmond
Field Value
Blue
An RGBA color with the value #0000FFFF.
public static readonly Color Blue
Field Value
BlueViolet
An RGBA color with the value #8A2BE2FF.
public static readonly Color BlueViolet
Field Value
Brown
An RGBA color with the value #A52A2AFF.
public static readonly Color Brown
Field Value
BurlyWood
An RGBA color with the value #DEB887FF.
public static readonly Color BurlyWood
Field Value
CadetBlue
An RGBA color with the value #5F9EA0FF.
public static readonly Color CadetBlue
Field Value
Chartreuse
An RGBA color with the value #7FFF00FF.
public static readonly Color Chartreuse
Field Value
Chocolate
An RGBA color with the value #D2691EFF.
public static readonly Color Chocolate
Field Value
Coral
An RGBA color with the value #FF7F50FF.
public static readonly Color Coral
Field Value
CornflowerBlue
An RGBA color with the value #6495EDFF.
public static readonly Color CornflowerBlue
Field Value
Cornsilk
An RGBA color with the value #FFF8DCFF.
public static readonly Color Cornsilk
Field Value
Crimson
An RGBA color with the value #DC143CFF.
public static readonly Color Crimson
Field Value
Cyan
An RGBA color with the value #00FFFFFF.
public static readonly Color Cyan
Field Value
DarkBlue
An RGBA color with the value #00008BFF.
public static readonly Color DarkBlue
Field Value
DarkCyan
An RGBA color with the value #008B8BFF.
public static readonly Color DarkCyan
Field Value
DarkGoldenrod
An RGBA color with the value #B8860BFF.
public static readonly Color DarkGoldenrod
Field Value
DarkGray
An RGBA color with the value #A9A9A9FF.
public static readonly Color DarkGray
Field Value
DarkGreen
An RGBA color with the value #006400FF.
public static readonly Color DarkGreen
Field Value
DarkKhaki
An RGBA color with the value #BDB76BFF.
public static readonly Color DarkKhaki
Field Value
DarkMagenta
An RGBA color with the value #8B008BFF.
public static readonly Color DarkMagenta
Field Value
DarkOliveGreen
An RGBA color with the value #556B2FFF.
public static readonly Color DarkOliveGreen
Field Value
DarkOrange
An RGBA color with the value #FF8C00FF.
public static readonly Color DarkOrange
Field Value
DarkOrchid
An RGBA color with the value #9932CCFF.
public static readonly Color DarkOrchid
Field Value
DarkRed
An RGBA color with the value #8B0000FF.
public static readonly Color DarkRed
Field Value
DarkSalmon
An RGBA color with the value #E9967AFF.
public static readonly Color DarkSalmon
Field Value
DarkSeaGreen
An RGBA color with the value #8FBC8BFF.
public static readonly Color DarkSeaGreen
Field Value
DarkSlateBlue
An RGBA color with the value #483D8BFF.
public static readonly Color DarkSlateBlue
Field Value
DarkSlateGray
An RGBA color with the value #2F4F4FFF.
public static readonly Color DarkSlateGray
Field Value
DarkTurquoise
An RGBA color with the value #00CED1FF.
public static readonly Color DarkTurquoise
Field Value
DarkViolet
An RGBA color with the value #9400D3FF.
public static readonly Color DarkViolet
Field Value
DeepPink
An RGBA color with the value #FF1493FF.
public static readonly Color DeepPink
Field Value
DeepSkyBlue
An RGBA color with the value #00BFFFFF.
public static readonly Color DeepSkyBlue
Field Value
DimGray
An RGBA color with the value #696969FF.
public static readonly Color DimGray
Field Value
DodgerBlue
An RGBA color with the value #1E90FFFF.
public static readonly Color DodgerBlue
Field Value
Firebrick
An RGBA color with the value #B22222FF.
public static readonly Color Firebrick
Field Value
FloralWhite
An RGBA color with the value #FFFAF0FF.
public static readonly Color FloralWhite
Field Value
ForestGreen
An RGBA color with the value #228B22FF.
public static readonly Color ForestGreen
Field Value
Fuchsia
An RGBA color with the value #FF00FFFF.
public static readonly Color Fuchsia
Field Value
Gainsboro
An RGBA color with the value #DCDCDCFF.
public static readonly Color Gainsboro
Field Value
GhostWhite
An RGBA color with the value #F8F8FFFF.
public static readonly Color GhostWhite
Field Value
Gold
An RGBA color with the value #FFD700FF.
public static readonly Color Gold
Field Value
Goldenrod
An RGBA color with the value #DAA520FF.
public static readonly Color Goldenrod
Field Value
Gray
An RGBA color with the value #808080FF.
public static readonly Color Gray
Field Value
Green
An RGBA color with the value #008000FF.
public static readonly Color Green
Field Value
GreenYellow
An RGBA color with the value #ADFF2FFF.
public static readonly Color GreenYellow
Field Value
Honeydew
An RGBA color with the value #F0FFF0FF.
public static readonly Color Honeydew
Field Value
HotPink
An RGBA color with the value #FF69B4FF.
public static readonly Color HotPink
Field Value
IndianRed
An RGBA color with the value #CD5C5CFF.
public static readonly Color IndianRed
Field Value
Indigo
An RGBA color with the value #4B0082FF.
public static readonly Color Indigo
Field Value
Ivory
An RGBA color with the value #FFFFF0FF.
public static readonly Color Ivory
Field Value
Khaki
An RGBA color with the value #F0E68CFF.
public static readonly Color Khaki
Field Value
Lavender
An RGBA color with the value #E6E6FAFF.
public static readonly Color Lavender
Field Value
LavenderBlush
An RGBA color with the value #FFF0F5FF.
public static readonly Color LavenderBlush
Field Value
LawnGreen
An RGBA color with the value #7CFC00FF.
public static readonly Color LawnGreen
Field Value
LemonChiffon
An RGBA color with the value #FFFACDFF.
public static readonly Color LemonChiffon
Field Value
LightBlue
An RGBA color with the value #ADD8E6FF.
public static readonly Color LightBlue
Field Value
LightCoral
An RGBA color with the value #F08080FF.
public static readonly Color LightCoral
Field Value
LightCyan
An RGBA color with the value #E0FFFFFF.
public static readonly Color LightCyan
Field Value
LightGoldenrodYellow
An RGBA color with the value #FAFAD2FF.
public static readonly Color LightGoldenrodYellow
Field Value
LightGray
An RGBA color with the value #D3D3D3FF.
public static readonly Color LightGray
Field Value
LightGreen
An RGBA color with the value #90EE90FF.
public static readonly Color LightGreen
Field Value
LightPink
An RGBA color with the value #FFB6C1FF.
public static readonly Color LightPink
Field Value
LightSalmon
An RGBA color with the value #FFA07AFF.
public static readonly Color LightSalmon
Field Value
LightSeaGreen
An RGBA color with the value #20B2AAFF.
public static readonly Color LightSeaGreen
Field Value
LightSkyBlue
An RGBA color with the value #87CEFAFF.
public static readonly Color LightSkyBlue
Field Value
LightSlateGray
An RGBA color with the value #778899FF.
public static readonly Color LightSlateGray
Field Value
LightSteelBlue
An RGBA color with the value #B0C4DEFF.
public static readonly Color LightSteelBlue
Field Value
LightYellow
An RGBA color with the value #FFFFE0FF.
public static readonly Color LightYellow
Field Value
Lime
An RGBA color with the value #00FF00FF.
public static readonly Color Lime
Field Value
LimeGreen
An RGBA color with the value #32CD32FF.
public static readonly Color LimeGreen
Field Value
Linen
An RGBA color with the value #FAF0E6FF.
public static readonly Color Linen
Field Value
Magenta
An RGBA color with the value #FF00FFFF.
public static readonly Color Magenta
Field Value
Maroon
An RGBA color with the value #800000FF.
public static readonly Color Maroon
Field Value
MediumAquamarine
An RGBA color with the value #66CDAAFF.
public static readonly Color MediumAquamarine
Field Value
MediumBlue
An RGBA color with the value #0000CDFF.
public static readonly Color MediumBlue
Field Value
MediumOrchid
An RGBA color with the value #BA55D3FF.
public static readonly Color MediumOrchid
Field Value
MediumPurple
An RGBA color with the value #9370DBFF.
public static readonly Color MediumPurple
Field Value
MediumSeaGreen
An RGBA color with the value #3CB371FF.
public static readonly Color MediumSeaGreen
Field Value
MediumSlateBlue
An RGBA color with the value #7B68EEFF.
public static readonly Color MediumSlateBlue
Field Value
MediumSpringGreen
An RGBA color with the value #00FA9AFF.
public static readonly Color MediumSpringGreen
Field Value
MediumTurquoise
An RGBA color with the value #48D1CCFF.
public static readonly Color MediumTurquoise
Field Value
MediumVioletRed
An RGBA color with the value #C71585FF.
public static readonly Color MediumVioletRed
Field Value
MidnightBlue
An RGBA color with the value #191970FF.
public static readonly Color MidnightBlue
Field Value
MintCream
An RGBA color with the value #F5FFFAFF.
public static readonly Color MintCream
Field Value
MistyRose
An RGBA color with the value #FFE4E1FF.
public static readonly Color MistyRose
Field Value
Moccasin
An RGBA color with the value #FFE4B5FF.
public static readonly Color Moccasin
Field Value
NavajoWhite
An RGBA color with the value #FFDEADFF.
public static readonly Color NavajoWhite
Field Value
Navy
An RGBA color with the value #000080FF.
public static readonly Color Navy
Field Value
OldLace
An RGBA color with the value #FDF5E6FF.
public static readonly Color OldLace
Field Value
Olive
An RGBA color with the value #808000FF.
public static readonly Color Olive
Field Value
OliveDrab
An RGBA color with the value #6B8E23FF.
public static readonly Color OliveDrab
Field Value
Orange
An RGBA color with the value #FFA500FF.
public static readonly Color Orange
Field Value
OrangeRed
An RGBA color with the value #FF4500FF.
public static readonly Color OrangeRed
Field Value
Orchid
An RGBA color with the value #DA70D6FF.
public static readonly Color Orchid
Field Value
PaleGoldenrod
An RGBA color with the value #EEE8AAFF.
public static readonly Color PaleGoldenrod
Field Value
PaleGreen
An RGBA color with the value #98FB98FF.
public static readonly Color PaleGreen
Field Value
PaleTurquoise
An RGBA color with the value #AFEEEEFF.
public static readonly Color PaleTurquoise
Field Value
PaleVioletRed
An RGBA color with the value #DB7093FF.
public static readonly Color PaleVioletRed
Field Value
PapayaWhip
An RGBA color with the value #FFEFD5FF.
public static readonly Color PapayaWhip
Field Value
PeachPuff
An RGBA color with the value #FFDAB9FF.
public static readonly Color PeachPuff
Field Value
Peru
An RGBA color with the value #CD853FFF.
public static readonly Color Peru
Field Value
Pink
An RGBA color with the value #FFC0CBFF.
public static readonly Color Pink
Field Value
Plum
An RGBA color with the value #DDA0DDFF.
public static readonly Color Plum
Field Value
PowderBlue
An RGBA color with the value #B0E0E6FF.
public static readonly Color PowderBlue
Field Value
Purple
An RGBA color with the value #800080FF.
public static readonly Color Purple
Field Value
RebeccaPurple
An RGBA color with the value #663399FF.
public static readonly Color RebeccaPurple
Field Value
Red
An RGBA color with the value #FF0000FF.
public static readonly Color Red
Field Value
RosyBrown
An RGBA color with the value #BC8F8FFF.
public static readonly Color RosyBrown
Field Value
RoyalBlue
An RGBA color with the value #4169E1FF.
public static readonly Color RoyalBlue
Field Value
SaddleBrown
An RGBA color with the value #8B4513FF.
public static readonly Color SaddleBrown
Field Value
Salmon
An RGBA color with the value #FA8072FF.
public static readonly Color Salmon
Field Value
SandyBrown
An RGBA color with the value #F4A460FF.
public static readonly Color SandyBrown
Field Value
SeaGreen
An RGBA color with the value #2E8B57FF.
public static readonly Color SeaGreen
Field Value
SeaShell
An RGBA color with the value #FFF5EEFF.
public static readonly Color SeaShell
Field Value
Sienna
An RGBA color with the value #A0522DFF.
public static readonly Color Sienna
Field Value
Silver
An RGBA color with the value #C0C0C0FF.
public static readonly Color Silver
Field Value
SkyBlue
An RGBA color with the value #87CEEBFF.
public static readonly Color SkyBlue
Field Value
SlateBlue
An RGBA color with the value #6A5ACDFF.
public static readonly Color SlateBlue
Field Value
SlateGray
An RGBA color with the value #708090FF.
public static readonly Color SlateGray
Field Value
Snow
An RGBA color with the value #FFFAFAFF.
public static readonly Color Snow
Field Value
SpringGreen
An RGBA color with the value #00FF7FFF.
public static readonly Color SpringGreen
Field Value
SteelBlue
An RGBA color with the value #4682B4FF.
public static readonly Color SteelBlue
Field Value
Tan
An RGBA color with the value #D2B48CFF.
public static readonly Color Tan
Field Value
Teal
An RGBA color with the value #008080FF.
public static readonly Color Teal
Field Value
Thistle
An RGBA color with the value #D8BFD8FF.
public static readonly Color Thistle
Field Value
Tomato
An RGBA color with the value #FF6347FF.
public static readonly Color Tomato
Field Value
Transparent
An RGBA color with the value #00000000.
public static readonly Color Transparent
Field Value
Turquoise
An RGBA color with the value #40E0D0FF.
public static readonly Color Turquoise
Field Value
Violet
An RGBA color with the value #EE82EEFF.
public static readonly Color Violet
Field Value
Wheat
An RGBA color with the value #F5DEB3FF.
public static readonly Color Wheat
Field Value
White
An RGBA color with the value #FFFFFFFF.
public static readonly Color White
Field Value
WhiteSmoke
An RGBA color with the value #F5F5F5FF.
public static readonly Color WhiteSmoke
Field Value
Yellow
An RGBA color with the value #FFFF00FF.
public static readonly Color Yellow
Field Value
YellowGreen
An RGBA color with the value #9ACD32FF.
public static readonly Color YellowGreen
Field Value
Properties
A
The 8-bit value of the alpha component of this color.
public byte A { get; init; }
Property Value
B
The 8-bit value of the blue component of this color.
public byte B { get; init; }
Property Value
G
The 8-bit value of the green component of this color.
public byte G { get; init; }
Property Value
R
The 8-bit value of the red component of this color.
public byte R { get; init; }
Property Value
Value
The 32-bit, RGBA value of this color.
public uint Value { get; init; }
Property Value
Methods
AsVector3()
public Vector3 AsVector3()
Returns
AsVector4()
public Vector4 AsVector4()
Returns
Equals(Color)
Indicates that this color is the same as another.
public bool Equals(Color other)
Parameters
other
ColorThe other color.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and this instance are the same type and represent the same value; otherwise, false.
FromHSV(Vector3)
Creates a color given a hue, saturation, and value.
public static Color FromHSV(Vector3 channels)
Parameters
channels
Vector3The channels of the color, where X is hue, Y is saturation, and Z is value.
Returns
- Color
The created color.
FromHSV(Vector4)
Creates a color given a hue, saturation, value, and alpha.
public static Color FromHSV(Vector4 channels)
Parameters
channels
Vector4The channels of the color, where X is hue, Y is saturation, Z is value, and W is alpha.
Returns
- Color
The created color.
FromHSV(float, float, float)
Creates a color given a hue, saturation, and value.
public static Color FromHSV(float hue, float saturation, float value)
Parameters
hue
floatThe hue of the color. This must be between 0 and 1.
saturation
floatThe saturation of the color. This must be between 0 and 1.
value
floatThe value (brightness) of the color. This must be between 0 and 1.
Returns
- Color
The created color.
FromHSV(float, float, float, float)
Creates a color given a hue, saturation, value, and alpha.
public static Color FromHSV(float hue, float saturation, float value, float alpha)
Parameters
hue
floatThe hue of the color. This must be between 0 and 1.
saturation
floatThe saturation of the color. This must be between 0 and 1.
value
floatThe value (brightness) of the color. This must be between 0 and 1.
alpha
floatThe alpha of the color. This must be between 0 and 1.
Returns
- Color
The created color.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Lerp(Color, Color, float)
Linearly interpolates between two Color values in RGBA space.
public static Color Lerp(Color color1, Color color2, float t)
Parameters
color1
ColorThe first color.
color2
ColorThe second color.
t
floatThe interpolation amount, from 0.0 to 1.0.
Returns
- Color
The interpolated color.
LerpHSV(Color, Color, float)
Linearly interpolates between two Color values in HSV space.
public static Color LerpHSV(Color color1, Color color2, float t)
Parameters
color1
ColorThe first color.
color2
ColorThe second color.
t
floatThe interpolation amount, from 0.0 to 1.0.
Returns
- Color
The interpolated color.
Parse(ReadOnlySpan<char>)
Converts to a color from its string representation.
public static Color Parse(ReadOnlySpan<char> value)
Parameters
value
ReadOnlySpan<char>The string representation of the color.
Returns
- Color
The color that the string represents.
Exceptions
Parse(string)
Converts to a color from its string representation.
public static Color Parse(string value)
Parameters
value
stringThe string representation of the color.
Returns
- Color
The color that the string represents.
Exceptions
ToColorF()
public ColorF ToColorF()
Returns
ToHSV()
Computes the values of this Color in the HSV color space.
public Vector3 ToHSV()
Returns
- Vector3
The computed values, where X is hue, Y is saturation, and Z is value.
ToHSVA()
Computes the values of this Color in the HSV color space.
public Vector4 ToHSVA()
Returns
- Vector4
The computed values, where X is hue, Y is saturation, Z is value, and W is alpha.
ToString()
Returns the hexadecimal-formatted value of this color.
public override string ToString()
Returns
TryParse(ReadOnlySpan<char>, out Color)
Attempts to converts to a color from its string representation.
public static bool TryParse(ReadOnlySpan<char> value, out Color result)
Parameters
value
ReadOnlySpan<char>The string representation of the color.
result
ColorThe value of the color.
Returns
TryParse(string, out Color)
Attempts to converts to a color from its string representation.
public static bool TryParse(string value, out Color result)
Parameters
Returns
Operators
operator ==(Color, Color)
Indicates if two Color objects are equal.
public static bool operator ==(Color left, Color right)
Parameters
Returns
explicit operator Color(Color)
public static explicit operator Color(Color value)
Parameters
value
ColorThe color to convert.
Returns
explicit operator uint(Color)
public static explicit operator uint(Color color)
Parameters
color
ColorThe color to convert.
Returns
explicit operator Color(Color)
public static explicit operator Color(Color value)
Parameters
value
ColorThe color to convert.
Returns
explicit operator Color(uint)
public static explicit operator Color(uint value)
Parameters
value
uint
Returns
operator !=(Color, Color)
Indicates if two Color objects are not equal.
public static bool operator !=(Color left, Color right)