Table of Contents

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 byte

The red component of the color.

g byte

The green component of the color.

b byte

The 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 byte

The red component of the color.

g byte

The green component of the color.

b byte

The blue component of the color.

a byte

The alpha component of the color.

Color(Vector3)

Creates a new color from the provided RGB values.

public Color(Vector3 values)

Parameters

values Vector3

The 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 Vector4

The 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 float

The red component of the color. This value should be between 0 and 1.

g float

The green component of the color. This value should be between 0 and 1.

b float

The 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 float

The red component of the color. This value should be between 0 and 1.

g float

The green component of the color. This value should be between 0 and 1.

b float

The blue component of the color. This value should be between 0 and 1.

a float

The 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 uint

The 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

Color

AntiqueWhite

An RGBA color with the value #FAEBD7FF.

public static readonly Color AntiqueWhite

Field Value

Color

Aqua

An RGBA color with the value #00FFFFFF.

public static readonly Color Aqua

Field Value

Color

Aquamarine

An RGBA color with the value #7FFFD4FF.

public static readonly Color Aquamarine

Field Value

Color

Azure

An RGBA color with the value #F0FFFFFF.

public static readonly Color Azure

Field Value

Color

Beige

An RGBA color with the value #F5F5DCFF.

public static readonly Color Beige

Field Value

Color

Bisque

An RGBA color with the value #FFE4C4FF.

public static readonly Color Bisque

Field Value

Color

Black

An RGBA color with the value #000000FF.

public static readonly Color Black

Field Value

Color

BlanchedAlmond

An RGBA color with the value #FFEBCDFF.

public static readonly Color BlanchedAlmond

Field Value

Color

Blue

An RGBA color with the value #0000FFFF.

public static readonly Color Blue

Field Value

Color

BlueViolet

An RGBA color with the value #8A2BE2FF.

public static readonly Color BlueViolet

Field Value

Color

Brown

An RGBA color with the value #A52A2AFF.

public static readonly Color Brown

Field Value

Color

BurlyWood

An RGBA color with the value #DEB887FF.

public static readonly Color BurlyWood

Field Value

Color

CadetBlue

An RGBA color with the value #5F9EA0FF.

public static readonly Color CadetBlue

Field Value

Color

Chartreuse

An RGBA color with the value #7FFF00FF.

public static readonly Color Chartreuse

Field Value

Color

Chocolate

An RGBA color with the value #D2691EFF.

public static readonly Color Chocolate

Field Value

Color

Coral

An RGBA color with the value #FF7F50FF.

public static readonly Color Coral

Field Value

Color

CornflowerBlue

An RGBA color with the value #6495EDFF.

public static readonly Color CornflowerBlue

Field Value

Color

Cornsilk

An RGBA color with the value #FFF8DCFF.

public static readonly Color Cornsilk

Field Value

Color

Crimson

An RGBA color with the value #DC143CFF.

public static readonly Color Crimson

Field Value

Color

Cyan

An RGBA color with the value #00FFFFFF.

public static readonly Color Cyan

Field Value

Color

DarkBlue

An RGBA color with the value #00008BFF.

public static readonly Color DarkBlue

Field Value

Color

DarkCyan

An RGBA color with the value #008B8BFF.

public static readonly Color DarkCyan

Field Value

Color

DarkGoldenrod

An RGBA color with the value #B8860BFF.

public static readonly Color DarkGoldenrod

Field Value

Color

DarkGray

An RGBA color with the value #A9A9A9FF.

public static readonly Color DarkGray

Field Value

Color

DarkGreen

An RGBA color with the value #006400FF.

public static readonly Color DarkGreen

Field Value

Color

DarkKhaki

An RGBA color with the value #BDB76BFF.

public static readonly Color DarkKhaki

Field Value

Color

DarkMagenta

An RGBA color with the value #8B008BFF.

public static readonly Color DarkMagenta

Field Value

Color

DarkOliveGreen

An RGBA color with the value #556B2FFF.

public static readonly Color DarkOliveGreen

Field Value

Color

DarkOrange

An RGBA color with the value #FF8C00FF.

public static readonly Color DarkOrange

Field Value

Color

DarkOrchid

An RGBA color with the value #9932CCFF.

public static readonly Color DarkOrchid

Field Value

Color

DarkRed

An RGBA color with the value #8B0000FF.

public static readonly Color DarkRed

Field Value

Color

DarkSalmon

An RGBA color with the value #E9967AFF.

public static readonly Color DarkSalmon

Field Value

Color

DarkSeaGreen

An RGBA color with the value #8FBC8BFF.

public static readonly Color DarkSeaGreen

Field Value

Color

DarkSlateBlue

An RGBA color with the value #483D8BFF.

public static readonly Color DarkSlateBlue

Field Value

Color

DarkSlateGray

An RGBA color with the value #2F4F4FFF.

public static readonly Color DarkSlateGray

Field Value

Color

DarkTurquoise

An RGBA color with the value #00CED1FF.

public static readonly Color DarkTurquoise

Field Value

Color

DarkViolet

An RGBA color with the value #9400D3FF.

public static readonly Color DarkViolet

Field Value

Color

DeepPink

An RGBA color with the value #FF1493FF.

public static readonly Color DeepPink

Field Value

Color

DeepSkyBlue

An RGBA color with the value #00BFFFFF.

public static readonly Color DeepSkyBlue

Field Value

Color

DimGray

An RGBA color with the value #696969FF.

public static readonly Color DimGray

Field Value

Color

DodgerBlue

An RGBA color with the value #1E90FFFF.

public static readonly Color DodgerBlue

Field Value

Color

Firebrick

An RGBA color with the value #B22222FF.

public static readonly Color Firebrick

Field Value

Color

FloralWhite

An RGBA color with the value #FFFAF0FF.

public static readonly Color FloralWhite

Field Value

Color

ForestGreen

An RGBA color with the value #228B22FF.

public static readonly Color ForestGreen

Field Value

Color

Fuchsia

An RGBA color with the value #FF00FFFF.

public static readonly Color Fuchsia

Field Value

Color

Gainsboro

An RGBA color with the value #DCDCDCFF.

public static readonly Color Gainsboro

Field Value

Color

GhostWhite

An RGBA color with the value #F8F8FFFF.

public static readonly Color GhostWhite

Field Value

Color

Gold

An RGBA color with the value #FFD700FF.

public static readonly Color Gold

Field Value

Color

Goldenrod

An RGBA color with the value #DAA520FF.

public static readonly Color Goldenrod

Field Value

Color

Gray

An RGBA color with the value #808080FF.

public static readonly Color Gray

Field Value

Color

Green

An RGBA color with the value #008000FF.

public static readonly Color Green

Field Value

Color

GreenYellow

An RGBA color with the value #ADFF2FFF.

public static readonly Color GreenYellow

Field Value

Color

Honeydew

An RGBA color with the value #F0FFF0FF.

public static readonly Color Honeydew

Field Value

Color

HotPink

An RGBA color with the value #FF69B4FF.

public static readonly Color HotPink

Field Value

Color

IndianRed

An RGBA color with the value #CD5C5CFF.

public static readonly Color IndianRed

Field Value

Color

Indigo

An RGBA color with the value #4B0082FF.

public static readonly Color Indigo

Field Value

Color

Ivory

An RGBA color with the value #FFFFF0FF.

public static readonly Color Ivory

Field Value

Color

Khaki

An RGBA color with the value #F0E68CFF.

public static readonly Color Khaki

Field Value

Color

Lavender

An RGBA color with the value #E6E6FAFF.

public static readonly Color Lavender

Field Value

Color

LavenderBlush

An RGBA color with the value #FFF0F5FF.

public static readonly Color LavenderBlush

Field Value

Color

LawnGreen

An RGBA color with the value #7CFC00FF.

public static readonly Color LawnGreen

Field Value

Color

LemonChiffon

An RGBA color with the value #FFFACDFF.

public static readonly Color LemonChiffon

Field Value

Color

LightBlue

An RGBA color with the value #ADD8E6FF.

public static readonly Color LightBlue

Field Value

Color

LightCoral

An RGBA color with the value #F08080FF.

public static readonly Color LightCoral

Field Value

Color

LightCyan

An RGBA color with the value #E0FFFFFF.

public static readonly Color LightCyan

Field Value

Color

LightGoldenrodYellow

An RGBA color with the value #FAFAD2FF.

public static readonly Color LightGoldenrodYellow

Field Value

Color

LightGray

An RGBA color with the value #D3D3D3FF.

public static readonly Color LightGray

Field Value

Color

LightGreen

An RGBA color with the value #90EE90FF.

public static readonly Color LightGreen

Field Value

Color

LightPink

An RGBA color with the value #FFB6C1FF.

public static readonly Color LightPink

Field Value

Color

LightSalmon

An RGBA color with the value #FFA07AFF.

public static readonly Color LightSalmon

Field Value

Color

LightSeaGreen

An RGBA color with the value #20B2AAFF.

public static readonly Color LightSeaGreen

Field Value

Color

LightSkyBlue

An RGBA color with the value #87CEFAFF.

public static readonly Color LightSkyBlue

Field Value

Color

LightSlateGray

An RGBA color with the value #778899FF.

public static readonly Color LightSlateGray

Field Value

Color

LightSteelBlue

An RGBA color with the value #B0C4DEFF.

public static readonly Color LightSteelBlue

Field Value

Color

LightYellow

An RGBA color with the value #FFFFE0FF.

public static readonly Color LightYellow

Field Value

Color

Lime

An RGBA color with the value #00FF00FF.

public static readonly Color Lime

Field Value

Color

LimeGreen

An RGBA color with the value #32CD32FF.

public static readonly Color LimeGreen

Field Value

Color

Linen

An RGBA color with the value #FAF0E6FF.

public static readonly Color Linen

Field Value

Color

Magenta

An RGBA color with the value #FF00FFFF.

public static readonly Color Magenta

Field Value

Color

Maroon

An RGBA color with the value #800000FF.

public static readonly Color Maroon

Field Value

Color

MediumAquamarine

An RGBA color with the value #66CDAAFF.

public static readonly Color MediumAquamarine

Field Value

Color

MediumBlue

An RGBA color with the value #0000CDFF.

public static readonly Color MediumBlue

Field Value

Color

MediumOrchid

An RGBA color with the value #BA55D3FF.

public static readonly Color MediumOrchid

Field Value

Color

MediumPurple

An RGBA color with the value #9370DBFF.

public static readonly Color MediumPurple

Field Value

Color

MediumSeaGreen

An RGBA color with the value #3CB371FF.

public static readonly Color MediumSeaGreen

Field Value

Color

MediumSlateBlue

An RGBA color with the value #7B68EEFF.

public static readonly Color MediumSlateBlue

Field Value

Color

MediumSpringGreen

An RGBA color with the value #00FA9AFF.

public static readonly Color MediumSpringGreen

Field Value

Color

MediumTurquoise

An RGBA color with the value #48D1CCFF.

public static readonly Color MediumTurquoise

Field Value

Color

MediumVioletRed

An RGBA color with the value #C71585FF.

public static readonly Color MediumVioletRed

Field Value

Color

MidnightBlue

An RGBA color with the value #191970FF.

public static readonly Color MidnightBlue

Field Value

Color

MintCream

An RGBA color with the value #F5FFFAFF.

public static readonly Color MintCream

Field Value

Color

MistyRose

An RGBA color with the value #FFE4E1FF.

public static readonly Color MistyRose

Field Value

Color

Moccasin

An RGBA color with the value #FFE4B5FF.

public static readonly Color Moccasin

Field Value

Color

NavajoWhite

An RGBA color with the value #FFDEADFF.

public static readonly Color NavajoWhite

Field Value

Color

Navy

An RGBA color with the value #000080FF.

public static readonly Color Navy

Field Value

Color

OldLace

An RGBA color with the value #FDF5E6FF.

public static readonly Color OldLace

Field Value

Color

Olive

An RGBA color with the value #808000FF.

public static readonly Color Olive

Field Value

Color

OliveDrab

An RGBA color with the value #6B8E23FF.

public static readonly Color OliveDrab

Field Value

Color

Orange

An RGBA color with the value #FFA500FF.

public static readonly Color Orange

Field Value

Color

OrangeRed

An RGBA color with the value #FF4500FF.

public static readonly Color OrangeRed

Field Value

Color

Orchid

An RGBA color with the value #DA70D6FF.

public static readonly Color Orchid

Field Value

Color

PaleGoldenrod

An RGBA color with the value #EEE8AAFF.

public static readonly Color PaleGoldenrod

Field Value

Color

PaleGreen

An RGBA color with the value #98FB98FF.

public static readonly Color PaleGreen

Field Value

Color

PaleTurquoise

An RGBA color with the value #AFEEEEFF.

public static readonly Color PaleTurquoise

Field Value

Color

PaleVioletRed

An RGBA color with the value #DB7093FF.

public static readonly Color PaleVioletRed

Field Value

Color

PapayaWhip

An RGBA color with the value #FFEFD5FF.

public static readonly Color PapayaWhip

Field Value

Color

PeachPuff

An RGBA color with the value #FFDAB9FF.

public static readonly Color PeachPuff

Field Value

Color

Peru

An RGBA color with the value #CD853FFF.

public static readonly Color Peru

Field Value

Color

Pink

An RGBA color with the value #FFC0CBFF.

public static readonly Color Pink

Field Value

Color

Plum

An RGBA color with the value #DDA0DDFF.

public static readonly Color Plum

Field Value

Color

PowderBlue

An RGBA color with the value #B0E0E6FF.

public static readonly Color PowderBlue

Field Value

Color

Purple

An RGBA color with the value #800080FF.

public static readonly Color Purple

Field Value

Color

RebeccaPurple

An RGBA color with the value #663399FF.

public static readonly Color RebeccaPurple

Field Value

Color

Red

An RGBA color with the value #FF0000FF.

public static readonly Color Red

Field Value

Color

RosyBrown

An RGBA color with the value #BC8F8FFF.

public static readonly Color RosyBrown

Field Value

Color

RoyalBlue

An RGBA color with the value #4169E1FF.

public static readonly Color RoyalBlue

Field Value

Color

SaddleBrown

An RGBA color with the value #8B4513FF.

public static readonly Color SaddleBrown

Field Value

Color

Salmon

An RGBA color with the value #FA8072FF.

public static readonly Color Salmon

Field Value

Color

SandyBrown

An RGBA color with the value #F4A460FF.

public static readonly Color SandyBrown

Field Value

Color

SeaGreen

An RGBA color with the value #2E8B57FF.

public static readonly Color SeaGreen

Field Value

Color

SeaShell

An RGBA color with the value #FFF5EEFF.

public static readonly Color SeaShell

Field Value

Color

Sienna

An RGBA color with the value #A0522DFF.

public static readonly Color Sienna

Field Value

Color

Silver

An RGBA color with the value #C0C0C0FF.

public static readonly Color Silver

Field Value

Color

SkyBlue

An RGBA color with the value #87CEEBFF.

public static readonly Color SkyBlue

Field Value

Color

SlateBlue

An RGBA color with the value #6A5ACDFF.

public static readonly Color SlateBlue

Field Value

Color

SlateGray

An RGBA color with the value #708090FF.

public static readonly Color SlateGray

Field Value

Color

Snow

An RGBA color with the value #FFFAFAFF.

public static readonly Color Snow

Field Value

Color

SpringGreen

An RGBA color with the value #00FF7FFF.

public static readonly Color SpringGreen

Field Value

Color

SteelBlue

An RGBA color with the value #4682B4FF.

public static readonly Color SteelBlue

Field Value

Color

Tan

An RGBA color with the value #D2B48CFF.

public static readonly Color Tan

Field Value

Color

Teal

An RGBA color with the value #008080FF.

public static readonly Color Teal

Field Value

Color

Thistle

An RGBA color with the value #D8BFD8FF.

public static readonly Color Thistle

Field Value

Color

Tomato

An RGBA color with the value #FF6347FF.

public static readonly Color Tomato

Field Value

Color

Transparent

An RGBA color with the value #00000000.

public static readonly Color Transparent

Field Value

Color

Turquoise

An RGBA color with the value #40E0D0FF.

public static readonly Color Turquoise

Field Value

Color

Violet

An RGBA color with the value #EE82EEFF.

public static readonly Color Violet

Field Value

Color

Wheat

An RGBA color with the value #F5DEB3FF.

public static readonly Color Wheat

Field Value

Color

White

An RGBA color with the value #FFFFFFFF.

public static readonly Color White

Field Value

Color

WhiteSmoke

An RGBA color with the value #F5F5F5FF.

public static readonly Color WhiteSmoke

Field Value

Color

Yellow

An RGBA color with the value #FFFF00FF.

public static readonly Color Yellow

Field Value

Color

YellowGreen

An RGBA color with the value #9ACD32FF.

public static readonly Color YellowGreen

Field Value

Color

Properties

A

The 8-bit value of the alpha component of this color.

public byte A { get; init; }

Property Value

byte

B

The 8-bit value of the blue component of this color.

public byte B { get; init; }

Property Value

byte

G

The 8-bit value of the green component of this color.

public byte G { get; init; }

Property Value

byte

R

The 8-bit value of the red component of this color.

public byte R { get; init; }

Property Value

byte

Value

The 32-bit, RGBA value of this color.

public uint Value { get; init; }

Property Value

uint

Methods

AsVector3()

Returns this Color as a Vector3, with its R, G, and B values as X, Y, and Z, respectively.

public Vector3 AsVector3()

Returns

Vector3

The converted Vector3.

AsVector4()

Converts this Color to Vector4, with its R, G, B, and A values as X, Y, Z, and W, respectively.

public Vector4 AsVector4()

Returns

Vector4

The converted Vector4.

Equals(Color)

Indicates that this color is the same as another.

public bool Equals(Color other)

Parameters

other Color

The other color.

Returns

bool

true if other and this instance represent the same value, otherwise false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The 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 Vector3

The 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 Vector4

The 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 float

The hue of the color. This must be between 0 and 1.

saturation float

The saturation of the color. This must be between 0 and 1.

value float

The 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 float

The hue of the color. This must be between 0 and 1.

saturation float

The saturation of the color. This must be between 0 and 1.

value float

The value (brightness) of the color. This must be between 0 and 1.

alpha float

The 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 Color

The first color.

color2 Color

The second color.

t float

The 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 Color

The first color.

color2 Color

The second color.

t float

The 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

ArgumentOutOfRangeException

Parse(string)

Converts to a color from its string representation.

public static Color Parse(string value)

Parameters

value string

The string representation of the color.

Returns

Color

The color that the string represents.

Exceptions

ArgumentOutOfRangeException

ToColorF()

Converts this Color as a ColorF.

public ColorF ToColorF()

Returns

ColorF

The converted ColorF.

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

string

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 Color

The value of the color.

Returns

bool

true if the string represents a color, otherwise false.

TryParse(string, out Color)

Attempts to converts to a color from its string representation.

public static bool TryParse(string value, out Color result)

Parameters

value string

The string representation of the color.

result Color

The value of the color.

Returns

bool

true if the string represents a color, otherwise false.

Operators

operator ==(Color, Color)

Indicates if two Color objects are equal.

public static bool operator ==(Color left, Color right)

Parameters

left Color

The first color.

right Color

The second color.

Returns

bool

true if the Color objects are equal, otherwise false.

explicit operator Color(Color)

Converts a Color to a Color.

public static explicit operator Color(Color value)

Parameters

value Color

The color to convert.

Returns

Color

explicit operator uint(Color)

Converts a Color to a uint.

public static explicit operator uint(Color color)

Parameters

color Color

The color to convert.

Returns

uint

explicit operator Color(Color)

Converts a Color to a Color.

public static explicit operator Color(Color value)

Parameters

value Color

The color to convert.

Returns

Color

explicit operator Color(uint)

Converts a uint to a Color.

public static explicit operator Color(uint value)

Parameters

value uint

Returns

Color

operator !=(Color, Color)

Indicates if two Color objects are not equal.

public static bool operator !=(Color left, Color right)

Parameters

left Color

The first color.

right Color

The second color.

Returns

bool

true if the Color objects are not equal, otherwise false.