Skip to content

API reference

Struct Color

Namespace: MicroEngine
Assembly: MicroEngine.Kernel.dll
Guide: Graphics

An 8-bit-per-channel, non-premultiplied RGBA color.

C#
public readonly struct Color : IEquatable<Color>

Implements

IEquatable<Color>

Constructors

Color(byte, byte, byte, byte)

An 8-bit-per-channel, non-premultiplied RGBA color.

C#
public Color(byte R, byte G, byte B, byte A = 255)

Parameters

R byte

Red, 0..255.

G byte

Green, 0..255.

B byte

Blue, 0..255.

A byte

Opacity, 0 (transparent) to 255 (opaque, the default).

Fields

Black

Opaque black.

C#
public static readonly Color Black

Field Value

Color

Transparent

Fully transparent black (0, 0, 0, 0).

C#
public static readonly Color Transparent

Field Value

Color

White

Opaque white. As a tint it leaves a texture unchanged.

C#
public static readonly Color White

Field Value

Color

Properties

A

Opacity, 0 (transparent) to 255 (opaque, the default).

C#
public byte A { get; init; }

Property Value

byte

B

Blue, 0..255.

C#
public byte B { get; init; }

Property Value

byte

G

Green, 0..255.

C#
public byte G { get; init; }

Property Value

byte

R

Red, 0..255.

C#
public byte R { get; init; }

Property Value

byte

Methods

Deconstruct(out byte, out byte, out byte, out byte)

C#
public void Deconstruct(out byte R, out byte G, out byte B, out byte A)

Parameters

R byte

G byte

B byte

A byte

Equals(object)

C#
public override bool Equals(object obj)

Parameters

obj object

Returns

bool

Equals(Color)

C#
public bool Equals(Color other)

Parameters

other Color

Returns

bool

GetHashCode()

C#
public override int GetHashCode()

Returns

int

Hex(string)

Parses “#RRGGBB” or “#RRGGBBAA” (the leading ‘#’ is optional).

C#
public static Color Hex(string hex)

Parameters

hex string

Returns

Color

Lerp(Color, Color, float)

Linear interpolation of every channel.

C#
public static Color Lerp(Color a, Color b, float t)

Parameters

a Color

b Color

t float

Returns

Color

Shade(float)

Multiplies RGB by factor; values above 1 brighten.

C#
public Color Shade(float factor)

Parameters

factor float

Returns

Color

ToString()

The colour as “#RRGGBBAA”, readable by Hex.

C#
public override string ToString()

Returns

string

WithAlpha(byte)

The same colour with opacity alpha (0..255).

C#
public Color WithAlpha(byte alpha)

Parameters

alpha byte

Returns

Color

WithAlpha(float)

The same colour with opacity alpha given as 0..1 (clamped; fractions of a step are truncated).

C#
public Color WithAlpha(float alpha)

Parameters

alpha float

Returns

Color

Operators

operator ==(Color, Color)

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

Parameters

left Color

right Color

Returns

bool

operator !=(Color, Color)

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

Parameters

left Color

right Color

Returns

bool