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
intThe 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
intThe intesity (brightness) value (0-255).
opacity
intThe 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
intRed color channel value (0-255).
g
intGreen color channel value (0-255).
b
intBlue 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
intRed color channel value (0-255).
g
intGreen color channel value (0-255).
b
intBlue color channel value (0-255).
a
intAlpha channel value (0-255).
Color(string)
Creates a new color from hex string.
public Color(string value)
Parameters
value
stringColor 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
Blue
RGB(0, 0, 255)
public static readonly Color Blue
Field Value
Clear
Fully transparent. RGBA(0, 0, 0, 0)
public static readonly Color Clear
Field Value
Cyan
RGB(0, 255, 255)
public static readonly Color Cyan
Field Value
DarkGray
RGB(63, 63, 63)
public static readonly Color DarkGray
Field Value
Gray
RGB(127, 127, 127)
public static readonly Color Gray
Field Value
Green
RGB(0, 255, 0)
public static readonly Color Green
Field Value
LightGray
RGB(195, 195, 195)
public static readonly Color LightGray
Field Value
Magenta
RGB(255, 0, 255)
public static readonly Color Magenta
Field Value
OffWhite
RGB(240, 240, 240)
public static readonly Color OffWhite
Field Value
Red
RGB(255, 0, 0)
public static readonly Color Red
Field Value
White
RGB(255, 255, 255)
public static readonly Color White
Field Value
Yellow
RGB(255, 255, 0)
public static readonly Color Yellow
Field Value
Properties
A
Alpha colour channel (0-255).
public int A { readonly get; set; }
Property Value
B
Blue colour channel (0-255).
public int B { readonly get; set; }
Property Value
G
Green colour channel (0-255).
public int G { readonly get; set; }
Property Value
R
Red colour channel (0-255).
public int R { readonly get; set; }
Property Value
Methods
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override readonly 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.
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
Returns
operator !=(Color, Color)
public static bool operator !=(Color lhs, Color rhs)