Color

Namespace: Murder.Core.Graphics
Assembly: Murder.dll

public sealed struct Color : IEquatable<T>

The color type as described by the engine. Values are represented as float from 0 to 1. To create a color using 0-255, use [Color.CreateFrom256(System.Byte,System.Byte,System.Byte,System.Byte)](../../../Murder/Core/Graphics/Color.html#createfrom256(byte,).

Implements: IEquatable<T>

⭐ Constructors

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

Creates a color with the specified values. If the fourth argument is omitted, the value used for the alpha will be 1, meaning a completely opaque color. Do note colors in Murder use 0-1 as their range. To initialize a color using 0-255, please refer to [Color.CreateFrom256(System.Byte,System.Byte,System.Byte,System.Byte)](../../../Murder/Core/Graphics/Color.html#createfrom256(byte,).

Parameters
r float

g float

b float

a float

⭐ Properties

A

public readonly float A;

Transparency of this color.

Returns
float

B

public readonly float B;

Amount of blue in this color.

Returns
float

Black

public static Color Black { get; }

Opaque color with 0 red, green or blue.

Returns
Color

Blue

public static Color Blue { get; }

Pure blue (no red or green).

Returns
Color

BrightGray

public static Color BrightGray { get; }

Opaque color with 65% red, 75% green and 75% blue.

Returns
Color

ColdGray

public static Color ColdGray { get; }

Like Color.Gray but with a blue-ish tint.

Returns
Color

Cyan

public static Color Cyan { get; }

Pure cyan (max green and blue, no red).

Returns
Color

G

public readonly float G;

Amount of green in this color.

Returns
float

Gray

public static Color Gray { get; }

Opaque color with 50% red, green and blue.

Returns
Color

Green

public static Color Green { get; }

Pure green (no red or blue).

Returns
Color

Magenta

public static Color Magenta { get; }

Pure magenta (max red and blue, no green).

Returns
Color

Orange

public static Color Orange { get; }

A shade of orange.

Returns
Color

R

public readonly float R;

Amount of red in this color.

Returns
float

Red

public static Color Red { get; }

Pure red (no green or blue).

Returns
Color

Transparent

public static Color Transparent { get; }

Color.Black but with 0 alpha.

Returns
Color

WarmGray

public static Color WarmGray { get; }

Like Color.Gray but with a red-ish tint.

Returns
Color

White

public static Color White { get; }

Opaque color with max red, green and blue.

Returns
Color

Yellow

public static Color Yellow { get; }

Pure yellow (max red and green, no blue).

Returns
Color

⭐ Methods

CreateFrom256(byte, byte, byte, byte)

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

Creates a color using values from 0 to 255.

Parameters
r byte
g byte
b byte
a byte

Returns
Color

CreateFrom256(byte, byte, byte)

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

Creates a color using values from 0 to 255.

Parameters
r byte
g byte
b byte

Returns
Color

Darken(float)

public Color Darken(float r)

Multiplies all values except the alpha by the factor . While this is named "Darken", values above 1.0f will effectively make the color lighter.

Parameters
r float

Returns
Color

FadeAlpha(float)

public Color FadeAlpha(float factor)

Keeps all color values equal except for the alpha which is multiplied by

Parameters
factor float

Returns
Color

FadeHalfAlpha(float)

public Color FadeHalfAlpha(float factor)

Fades all the colors by halft the factor, except for the alpha which is fully faded.

Parameters
factor float

Returns
Color

FromHex(string)

public Color FromHex(string hex)

Parses a string to Color.

Parameters
hex string

Returns
Color

Lerp(Color, Color, float)

public Color Lerp(Color a, Color b, float factor)

Finds a color that is in the point between and .

Parameters
a Color
b Color
factor float

Returns
Color

LerpSmooth(Color, Color, float, float)

public Color LerpSmooth(Color a, Color b, float deltaTime, float halfLife)

Parameters
a Color
b Color
deltaTime float
halfLife float

Returns
Color

Parse(string)

public Color Parse(string str)

Tries to interpret a color from a string. Returns Color.Magenta in case of failure.

Parameters
str string

Returns
Color

Premultiply()

public Color Premultiply()

Multiplies the R, G and B values of this color by the Alpha value.

Returns
Color

ToUint(Vector4)

public uint ToUint(Vector4 color)

Interprets the Vector4 as a color and return the unsigned integer representation of that color.

Parameters
color Vector4

Returns
uint

ToSysVector4()

public Vector4 ToSysVector4()

Converts this color into a Vector4 with X = R, Y = G, Z = B and W = A.

Returns
Vector4

Equals(Color)

public virtual bool Equals(Color other)

Checks if two colors are equal.

Parameters
other Color

Returns
bool

Equals(Object)

public virtual bool Equals(Object obj)

Parameters
obj Object

Returns
bool

GetHashCode()

public virtual int GetHashCode()

Returns
int

ToString()

public virtual string ToString()

Returns
string