Table of Contents

Struct Color

Namespace
Kook
Assembly
Kook.Net.Core.dll

Represents a color used in Kook.

public readonly struct Color
Inherited Members

Constructors

Color(byte, byte, byte)

Initializes a Color struct with the given RGB bytes.

public Color(byte r, byte g, byte b)

Parameters

r byte

The byte that represents the red color.

g byte

The byte that represents the green color.

b byte

The byte that represents the blue color.

Examples

The following will create a color that has a value of #607D8B.

Color darkGrey = new Color((byte)0b_01100000, (byte)0b_01111101, (byte)0b_10001011);

Exceptions

ArgumentException

Value exceeds MaxDecimalValue.

Color(int, int, int)

Initializes a Color struct with the given RGB value.

public Color(int r, int g, int b)

Parameters

r int

The value that represents the red color. Must be within 0~255.

g int

The value that represents the green color. Must be within 0~255.

b int

The value that represents the blue color. Must be within 0~255.

Examples

The following will create a color that has a value of #607D8B.

Color darkGrey = new Color(96, 125, 139);

Exceptions

ArgumentOutOfRangeException

The argument value is not between 0 to 255.

Color(float, float, float)

Initializes a Color struct with the given RGB float value.

public Color(float r, float g, float b)

Parameters

r float

The value that represents the red color. Must be within 0~1.

g float

The value that represents the green color. Must be within 0~1.

b float

The value that represents the blue color. Must be within 0~1.

Examples

The following will create a color that has a value of #607C8C.

Color darkGrey = new Color(0.38f, 0.49f, 0.55f);

Exceptions

ArgumentOutOfRangeException

The argument value is not between 0 to 1.

Color(uint)

Initializes a Color struct with the given raw value.

public Color(uint rawValue)

Parameters

rawValue uint

The raw value of the color (e.g. 0x607D8B).

Examples

The following will create a color that has a hex value of #607D8B.

Color darkGrey = new Color(0x607D8B);

Exceptions

ArgumentException

Value exceeds MaxDecimalValue.

Fields

Blue

Gets the blue color value.

public static readonly Color Blue

Field Value

Color

A color struct with the hex value of 3498DB.

See http://www.color-hex.com/color/3498DB

DarkBlue

Gets the dark blue color value.

public static readonly Color DarkBlue

Field Value

Color

A color struct with the hex value of 206694.

See http://www.color-hex.com/color/206694

DarkGreen

Gets the dark green color value.

public static readonly Color DarkGreen

Field Value

Color

A color struct with the hex value of 1F8B4C.

See http://www.color-hex.com/color/1F8B4C

DarkGrey

Gets the dark grey color value.

public static readonly Color DarkGrey

Field Value

Color

A color struct with the hex value of 607D8B.

See http://www.color-hex.com/color/607D8B

DarkMagenta

Gets the dark magenta color value.

public static readonly Color DarkMagenta

Field Value

Color

A color struct with the hex value of AD1457.

See http://www.color-hex.com/color/AD1457

DarkOrange

Gets the dark orange color value.

public static readonly Color DarkOrange

Field Value

Color

A color struct with the hex value of A84300.

See http://www.color-hex.com/color/A84300

DarkPurple

Gets the dark purple color value.

public static readonly Color DarkPurple

Field Value

Color

A color struct with the hex value of 71368A.

See http://www.color-hex.com/color/71368A

DarkRed

Gets the dark red color value.

public static readonly Color DarkRed

Field Value

Color

A color struct with the hex value of 992D22.

See http://www.color-hex.com/color/992D22

DarkTeal

Gets the dark teal color value.

public static readonly Color DarkTeal

Field Value

Color

A color struct with the hex value of 11806A.

See http://www.color-hex.com/color/11806A

DarkerGrey

Gets the darker grey color value.

public static readonly Color DarkerGrey

Field Value

Color

A color struct with the hex value of 3A4B53.

See http://www.color-hex.com/color/3A4B53

Default

Gets the default user color value.

public static readonly Color Default

Field Value

Color

Gold

Gets the gold color value.

public static readonly Color Gold

Field Value

Color

A color struct with the hex value of F1C40F.

See http://www.color-hex.com/color/F1C40F

Green

Gets the green color value.

public static readonly Color Green

Field Value

Color

A color struct with the hex value of 2ECC71.

See http://www.color-hex.com/color/2ECC71

Grey

Gets the grey color value.

public static readonly Color Grey

Field Value

Color

A color struct with the hex value of 666D71.

See http://www.color-hex.com/color/666D71

LightGrey

Gets the light grey color value.

public static readonly Color LightGrey

Field Value

Color

A color struct with the hex value of 95A5A6.

See http://www.color-hex.com/color/95A5A6

LightOrange

Gets the light orange color value.

public static readonly Color LightOrange

Field Value

Color

A color struct with the hex value of C27C0E.

See http://www.color-hex.com/color/C27C0E

Magenta

Gets the magenta color value.

public static readonly Color Magenta

Field Value

Color

A color struct with the hex value of E91E63.

See http://www.color-hex.com/color/E91E63

MaxDecimalValue

Gets the max decimal value of color.

public const uint MaxDecimalValue = 16777215

Field Value

uint

Orange

Gets the orange color value.

public static readonly Color Orange

Field Value

Color

A color struct with the hex value of E67E22.

See http://www.color-hex.com/color/E67E22

Purple

Gets the purple color value.

public static readonly Color Purple

Field Value

Color

A color struct with the hex value of 9B59B6.

See http://www.color-hex.com/color/9B59B6

Red

Gets the red color value.

public static readonly Color Red

Field Value

Color

A color struct with the hex value of E74C3C.

See http://www.color-hex.com/color/E74C3C

Teal

Gets the teal color value.

public static readonly Color Teal

Field Value

Color

A color struct with the hex value of 1ABC9C.

See http://www.color-hex.com/color/1ABC9C

Properties

B

Gets the blue component for this color.

public byte B { get; }

Property Value

byte

G

Gets the green component for this color.

public byte G { get; }

Property Value

byte

R

Gets the red component for this color.

public byte R { get; }

Property Value

byte

RawValue

Gets the encoded value for this color.

public uint RawValue { get; }

Property Value

uint

Remarks

This value is encoded as an unsigned integer value. The most-significant 8 bits contain the red value, the middle 8 bits contain the green value, and the least-significant 8 bits contain the blue value.

Methods

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.

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.

ToString()

Gets the hexadecimal representation of the color (e.g. #000ccc).

public override string ToString()

Returns

string

A hexadecimal string of the color.

Operators

operator ==(Color, Color)

Determines whether the specified Color is equal to this instance.

public static bool operator ==(Color lhs, Color rhs)

Parameters

lhs Color
rhs Color

Returns

bool

true if the specified Color is equal to this instance; otherwise, false .

explicit operator Color(Color)

Converts the given .NET standard Color to a Kook.Net-defined Color.

public static explicit operator Color(Color color)

Parameters

color Color

The .NET standard Color to convert.

Returns

Color

The Kook.Net-defined Color that represents the given .NET standard Color.

implicit operator Color(Color)

Converts the given Kook.Net-defined Color to a .NET standard Color.

public static implicit operator Color(Color color)

Parameters

color Color

The Kook.Net-defined Color to convert.

Returns

Color

The .NET standard Color that represents the given Kook.Net-defined Color.

implicit operator uint(Color)

Converts the given Color to its raw value of uint.

public static implicit operator uint(Color color)

Parameters

color Color

The Color to convert.

Returns

uint

The raw value of the given Color.

implicit operator Color(uint)

Converts the given raw value of uint to a Color.

public static implicit operator Color(uint rawValue)

Parameters

rawValue uint

The raw value of the color.

Returns

Color

The Color that represents the given raw value.

operator !=(Color, Color)

Determines whether the specified Color is not equal to this instance.

public static bool operator !=(Color lhs, Color rhs)

Parameters

lhs Color
rhs Color

Returns

bool

true if the specified Color is not equal to this instance; otherwise, false .