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
Darker(Color)
Returns a color darker than the given color.
public static Color Darker(this Color color)
Parameters
color
Color
Returns
Invert(Color)
Returns a new color that is this color inverted.
public static Color Invert(this Color color)
Parameters
color
ColorThe color to invert.
Returns
IsApproximatelyBlack(Color)
Returns whether the color is black or almost black.
public static bool IsApproximatelyBlack(this Color color)
Parameters
color
Color
Returns
IsApproximatelyWhite(Color)
Returns whether the color is white or almost white.
public static bool IsApproximatelyWhite(this Color color)
Parameters
color
Color
Returns
Lighter(Color)
Returns a color lighter than the given color.
public static Color Lighter(this Color color)
Parameters
color
Color
Returns
Opaque(Color)
Returns an opaque version of the given color.
public static Color Opaque(this Color color)
Parameters
color
Color
Returns
WithAlpha(Color, float)
Returns the same color, but with the specified alpha.
public static Color WithAlpha(this Color color, float alpha)
Parameters
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
Returns
Remarks
If the color is too dark, a grey is returned with the right brightness. The alpha is left unchanged.