Menu - Top - Home - Donate to Me

PeterO.ColorValidator

PeterO.ColorValidator

public static class ColorValidator

Contains methods to convert between different representations of HTML and CSS colors.

ColorHtmlToRgba

public static double[] ColorHtmlToRgba(
    string x);

Converts HTML colors to Red/Green/Blue colors.

Parameters:

Return Value:

An array of four elements, each from 0 to 255: the red, green, blue, and alpha components, in that order.

Exceptions:

ColorToRgb

public static double[] ColorToRgb(
    string x);

Converts HTML colors to Red/Green/Blue colors. Use this function to parse colors from normal color picker controls: http://peteroupc.github.com/colorpicker/.

Parameters:

Return Value:

A double[] object.

ColorToRgba

public static double[] ColorToRgba(
    string x);

Not documented yet.

Parameters:

Return Value:

Not documented yet.

HlsToRgb

public static double[] HlsToRgb(
    double[] hls);

Converts a color in the HLS color space to red/green/blue.

Parameters:

Return Value:

An array of three elements, each from 0 to 255: the red, green, and blue components, in that order.

Exceptions:

RgbToColor

public static string RgbToColor(
    double[] arrayRGB);

Converts an RGBA color to a string, either rgb(...) or rgba(...) as applicable.

Parameters:

Return Value:

A string object.

Exceptions:

RgbToColorDisplay

public static string RgbToColorDisplay(
    double[] rgb);

Converts a red-green-blue-alpha color to a string in CSS format.

Parameters:

Return Value:

A string object.

Exceptions:

RgbToColorHtml

public static string RgbToColorHtml(
    double r,
    double g,
    double b);

Converts a red-green-blue color to a string in HTML format.

Parameters:

Return Value:

A string object.

RgbToColorHtml

public static string RgbToColorHtml(
    double[] rgb);

Converts an RGBA color to an HTML color, (ex. #002233)."rgb" must contain at least 3 elements: the red, green, and blue (each 0-255).

Parameters:

Return Value:

A string object.

Exceptions:

Back to colorvalidator start page.