Table of Contents

Class ColorExtensions

Namespace
Gamelogic.Extensions
Assembly
Assembly-CSharp.dll

Provides some utility functions for Colors.

[Version(1, 0, 0)]
public static class ColorExtensions
Inheritance
ColorExtensions
Inherited Members

Methods

Brightness(Color)

Returns the brightness of the color, defined as the average off the three color channels.

public static float Brightness(this Color color)

Parameters

color Color

Returns

float

Darker(Color)

Returns a color darker than the given color.

public static Color Darker(this Color color)

Parameters

color Color

Returns

Color

Invert(Color)

Returns a new color that is this color inverted.

public static Color Invert(this Color color)

Parameters

color Color

The color to invert.

Returns

Color

IsApproximatelyBlack(Color)

Returns whether the color is black or almost black.

public static bool IsApproximatelyBlack(this Color color)

Parameters

color Color

Returns

bool

IsApproximatelyWhite(Color)

Returns whether the color is white or almost white.

public static bool IsApproximatelyWhite(this Color color)

Parameters

color Color

Returns

bool

Lighter(Color)

Returns a color lighter than the given color.

public static Color Lighter(this Color color)

Parameters

color Color

Returns

Color

Opaque(Color)

Returns an opaque version of the given color.

public static Color Opaque(this Color color)

Parameters

color Color

Returns

Color

WithAlpha(Color, float)

Returns the same color, but with the specified alpha.

public static Color WithAlpha(this Color color, float alpha)

Parameters

color Color

The color.

alpha float

The alpha.

Returns

Color

Color.

WithBrightness(Color, float)

Returns a new color with the RGB values scaled so that the color has the given brightness.

public static Color WithBrightness(this Color color, float brightness)

Parameters

color Color
brightness float

Returns

Color

Remarks

If the color is too dark, a grey is returned with the right brightness. The alpha is left unchanged.