A CSS string describing a color.
Output color.
Error message. null on success.
A specified Color, that keeps the intent of the user. This is not necessarily usable right away, and will typically need sRGB conversion. In other words, colors stay in their colorspace of definition.
import colors; // all HTML named colors parseCSSColor("black", color, error); // hex colors including alpha versions parseCSSColor("#fe85dc", color, error); // alpha parseCSSColor("rgba(64, 255, 128, 0.24)", color, error); // percentage, floating-point parseCSSColor("rgb(9e-1, 50%, 128)", color, error); // hsv colors parseCSSColor("hsl(120deg, 25%, 75%)", color, error); // gray colors parseCSSColor("gray(0.5)", color, error); // strips whitespace parseCSSColor(" rgb ( 245 , 112 , 74 ) ", color, error);
Parses a CSS color string, and gives back a Color.