Creating and Parsing Colors
Create concrete color values from CSS text, channels, constructors, and alpha values.
In this chapter
Read in order or jump directly to a specific page.
-
Supported concrete color input→
Identify the concrete CSS color values PHPColor can parse, the typed object each syntax produces, and the boundary with contextual CSS.
-
Choose text or channel input→
Choose between parsing text, normalizing an existing object, and constructing channels whose color space and numeric scale are already known.
-
Choose an invalid-input contract→
Decide when malformed color input should raise a parsing exception, return null, or pass into a separate application policy check.
-
Use named constructors→
Decide when a code-owned color should use a named constant and when its value should remain data.
-
Concrete and deferred CSS colors→
Decide whether a CSS color can resolve immediately or must retain variables, currentColor, or color-scheme choices until context is available.
-
Work with alpha values→
Choose where transparency belongs, preserve it through transformations, and serialize it without changing channel order.
-
Choose a normalization boundary→
Decide when to preserve a parsed color space, convert into working coordinates, and serialize a stable representation for another system.
-
Parse and find named colors→
Use CSS names as recognized input or approximate labels without confusing either role with color identity.