Show / Hide Table of Contents

Class ColorHelper

Color Utility Methods. ColorUtility exists already, so we will call it Color helper.

Inheritance
System.Object
ColorHelper
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ToString()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: StansAssets.Foundation
Assembly: cs.temp.dll.dll
Syntax
public static class ColorHelper

Methods

MakeColorFromHtml(String)

Attempts to make a color struct from the html color string. If parsing is failed magenta color will be returned.

Strings that begin with '#' will be parsed as hexadecimal in the following way:

RGB (becomes RRGGBB)

RRGGBB

RGBA (becomes RRGGBBAA)

RRGGBBAA

When not specified alpha will default to FF. Strings that do not begin with '#' will be parsed as literal colors, with the following supported: red, cyan, blue, darkblue, lightblue, purple, yellow, lime, fuchsia, white, silver, grey, black, orange, brown, maroon, green, olive, navy, teal, aqua, magenta..

Declaration
public static Color MakeColorFromHtml(string htmlString)
Parameters
Type Name Description
System.String htmlString

Case insensitive html string to be converted into a color.

Returns
Type Description
Color

The converted color.

MakeColorFromHtml(String, Color)

Attempts to make a color struct from the html color string. If parsing is failed color will be returned.

Strings that begin with '#' will be parsed as hexadecimal in the following way:

RGB (becomes RRGGBB)

RRGGBB

RGBA (becomes RRGGBBAA)

RRGGBBAA

When not specified alpha will default to FF. Strings that do not begin with '#' will be parsed as literal colors, with the following supported: red, cyan, blue, darkblue, lightblue, purple, yellow, lime, fuchsia, white, silver, grey, black, orange, brown, maroon, green, olive, navy, teal, aqua, magenta..

Declaration
public static Color MakeColorFromHtml(string htmlString, Color fallbackColor)
Parameters
Type Name Description
System.String htmlString

Case insensitive html string to be converted into a color.

Color fallbackColor

Color to fall back to in case the parsing is failed.

Returns
Type Description
Color

The converted color.

In This Article
Back to top Generated by DocFX