Table of Contents

Struct Color

Namespace
MohawkGame2D
Assembly
GAME 10003 Game Development Foundations - 2D Game Template.dll

Represents an RGBA color (32-bit) using 8-bit byte color components (numbers from 0 to 255).

public struct Color
Inherited Members

Constructors

Color()

Create a new color. Black.

public Color()

Color(int)

Create a new grayscale color using the intensity value.

public Color(int intensity)

Parameters

intensity int

The intesity (brightness) value (0-255).

Color(int, int)

Create a new grayscale color using the intensity value with opacity.

public Color(int intensity, int opacity)

Parameters

intensity int

The intesity (brightness) value (0-255).

opacity int

The opacity value, 0 for fully translucid, 255 for fully opaque.

Color(int, int, int)

Creates a new RGB color.

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

Parameters

r int

Red color channel value (0-255).

g int

Green color channel value (0-255).

b int

Blue color channel value (0-255).

Color(int, int, int, int)

Creates a new RGBA color.

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

Parameters

r int

Red color channel value (0-255).

g int

Green color channel value (0-255).

b int

Blue color channel value (0-255).

a int

Alpha channel value (0-255).

Color(string)

Creates a new color from hex string.

public Color(string value)

Parameters

value string

Color value as hex string.

Remarks

Color components are ordered R, G, B, A. Valid inputs include hex color "rrggbb", "rrggbbaa", such as "ff00aa" and "00bb7780". Leading # is permitted, such as "#ffddaa".

Fields

Black

RGB(0, 0, 0)

public static readonly Color Black

Field Value

Color

Blue

RGB(0, 0, 255)

public static readonly Color Blue

Field Value

Color

Clear

Fully transparent. RGBA(0, 0, 0, 0)

public static readonly Color Clear

Field Value

Color

Cyan

RGB(0, 255, 255)

public static readonly Color Cyan

Field Value

Color

DarkGray

RGB(63, 63, 63)

public static readonly Color DarkGray

Field Value

Color

Gray

RGB(127, 127, 127)

public static readonly Color Gray

Field Value

Color

Green

RGB(0, 255, 0)

public static readonly Color Green

Field Value

Color

LightGray

RGB(195, 195, 195)

public static readonly Color LightGray

Field Value

Color

Magenta

RGB(255, 0, 255)

public static readonly Color Magenta

Field Value

Color

OffWhite

RGB(240, 240, 240)

public static readonly Color OffWhite

Field Value

Color

Red

RGB(255, 0, 0)

public static readonly Color Red

Field Value

Color

White

RGB(255, 255, 255)

public static readonly Color White

Field Value

Color

Yellow

RGB(255, 255, 0)

public static readonly Color Yellow

Field Value

Color

Properties

A

Alpha colour channel (0-255).

public int A { readonly get; set; }

Property Value

int

B

Blue colour channel (0-255).

public int B { readonly get; set; }

Property Value

int

G

Green colour channel (0-255).

public int G { readonly get; set; }

Property Value

int

R

Red colour channel (0-255).

public int R { readonly get; set; }

Property Value

int

Methods

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override readonly 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 readonly int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

ToString()

Returns the fully qualified type name of this instance.

public override readonly string ToString()

Returns

string

The fully qualified type name.

Operators

operator ==(Color, Color)

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

Parameters

lhs Color
rhs Color

Returns

bool

operator !=(Color, Color)

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

Parameters

lhs Color
rhs Color

Returns

bool