Class ColorHelpers
A set of utilities for working with colors.
Inherited Members
Namespace: Ritchie.Toolbox
Assembly: Ritchie.Toolbox.dll
Syntax
public static class ColorHelpers
Methods
Brighten(Color, float)
Increase the brightness of a given color by a given amount.
Declaration
public static Color Brighten(this Color color, float amountPercentage)
Parameters
Type | Name | Description |
---|---|---|
Color | color | The color to brighten. |
float | amountPercentage | A percentage amount to brighten the color by. |
Returns
Type | Description |
---|---|
Color | A brighter version of the color. |
Darken(Color, float)
Darken a color by the given amount.
Declaration
public static Color Darken(this Color color, float amountPercentage)
Parameters
Type | Name | Description |
---|---|---|
Color | color | A color to darken. |
float | amountPercentage | A percentage amount to darken the color by. |
Returns
Type | Description |
---|---|
Color | A darkened version of the color. |
ParseColor(string, out Color)
Try to parse a string representation of a color into its corresponding Microsoft.Xna.Framework.Color value.
Declaration
public static bool ParseColor(string colorString, out Color color)
Parameters
Type | Name | Description |
---|---|---|
string | colorString | The representation of a color as text. |
Color | color | The resulting color. Will be set to transparent black if parsing failed. |
Returns
Type | Description |
---|---|
bool | True if the color is valid, false otherwise. |
Remarks
<p>
A color may be represented in the following formats:
</p>
<ul><li><span class="term">Named colors:</span><code>red</code>, <code>green</code>, <code>cyan</code></li><li><span class="term">32-bit RGB or 32-bit RGBA:</span><code>#rrggbbaa</code> or <code>#rrggbb</code></li><li><span class="term">Web colors:</span><code>#rgb</code> or <code>#rgba</code></li></ul>
<p>
Named colors are case-insensitive. HTML-style colors are also case-insensitive, but the <code>#</code> symbol is necessary.
</p>