Table of Contents

Struct AlphaColor

Namespace
Kook
Assembly
Kook.Net.Core.dll

Represents a Color with an alpha channel.

public readonly struct AlphaColor
Inherited Members

Constructors

AlphaColor(Color, byte)

Initializes a AlphaColor struct with the given base color and alpha channel.

public AlphaColor(Color baseColor, byte alpha)

Parameters

baseColor Color

The base color to use.

alpha byte

The byte that represents the alpha channel.

Exceptions

ArgumentException

Value exceeds MaxDecimalValue.

AlphaColor(byte, byte, byte, byte)

Initializes a AlphaColor struct with the given RGBA bytes.

public AlphaColor(byte r, byte g, byte b, byte a)

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.

a byte

The byte that represents the alpha channel.

Examples

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

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

Exceptions

ArgumentException

Value exceeds MaxDecimalValue.

AlphaColor(int, int, int, int)

Initializes a AlphaColor struct with the given RGBA value.

public AlphaColor(int r, int g, int b, int a)

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.

a int

The value that represents the alpha channel. Must be within 0~255.

Examples

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

AlphaColor darkGrey = new AlphaColor(96, 125, 139, 255);

Exceptions

ArgumentOutOfRangeException

The argument value is not between 0 to 255.

AlphaColor(float, float, float, float)

Initializes a AlphaColor struct with the given RGBA float value.

public AlphaColor(float r, float g, float b, float a)

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.

a float

The value that represents the alpha channel. Must be within 0~1.

Examples

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

AlphaColor darkGrey = new AlphaColor(0.38f, 0.49f, 0.55f, 1.00f);

Exceptions

ArgumentOutOfRangeException

The argument value is not between 0 to 1.

AlphaColor(ulong)

Initializes a new instance of the AlphaColor struct with the specified raw value.

public AlphaColor(ulong rawValue)

Parameters

rawValue ulong

The raw value to use.

Fields

Default

Gets the default user color value.

public static readonly AlphaColor Default

Field Value

AlphaColor

MaxDecimalValue

Gets the max decimal value of an color with an alpha channel.

public const ulong MaxDecimalValue = 4294967295

Field Value

ulong

Properties

A

Gets the alpha component for this color.

public byte A { get; }

Property Value

byte

B

Gets the blue component for this color.

public byte B { get; }

Property Value

byte

BaseColor

Gets the base color for this color without the alpha channel.

public Color BaseColor { get; }

Property Value

Color

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 raw value for this color.

public ulong RawValue { get; }

Property Value

ulong

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. #000cccff).

public override string ToString()

Returns

string

A hexadecimal string of the color.

Operators

operator ==(AlphaColor, AlphaColor)

Determines whether the specified AlphaColor is equal to this instance.

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

Parameters

lhs AlphaColor
rhs AlphaColor

Returns

bool

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

explicit operator Color(AlphaColor)

Converts the given Kook.Net-defined AlphaColor to a Kook.Net-defined Color.

public static explicit operator Color(AlphaColor color)

Parameters

color AlphaColor

The Kook.Net-defined AlphaColor to convert.

Returns

Color

The Kook.Net-defined Color that represents the given Kook.Net-defined AlphaColor.

Remarks

warning

This conversion will drop the alpha channel of the given AlphaColor.

explicit operator AlphaColor(Color)

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

public static explicit operator AlphaColor(Color color)

Parameters

color Color

The .NET standard Color to convert.

Returns

AlphaColor

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

implicit operator Color(AlphaColor)

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

public static implicit operator Color(AlphaColor color)

Parameters

color AlphaColor

The Kook.Net-defined AlphaColor to convert.

Returns

Color

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

implicit operator ulong(AlphaColor)

Converts the given AlphaColor to its raw value of uint.

public static implicit operator ulong(AlphaColor color)

Parameters

color AlphaColor

The AlphaColor to convert.

Returns

ulong

The raw value of the given AlphaColor.

implicit operator AlphaColor(Color)

Converts the given Kook.Net-defined Color to a Kook.Net-defined AlphaColor.

public static implicit operator AlphaColor(Color color)

Parameters

color Color

The Kook.Net-defined Color to convert.

Returns

AlphaColor

The Kook.Net-defined AlphaColor that represents the given Kook.Net-defined Color.

implicit operator AlphaColor(ulong)

Converts the given raw value of uint to a AlphaColor.

public static implicit operator AlphaColor(ulong rawValue)

Parameters

rawValue ulong

The raw value of the color.

Returns

AlphaColor

The AlphaColor that represents the given raw value.

operator !=(AlphaColor, AlphaColor)

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

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

Parameters

lhs AlphaColor
rhs AlphaColor

Returns

bool

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