Skip to content

Documentation / @ripl/core / parsePattern

Function: parsePattern() ​

parsePattern(value): Pattern | null

Defined in: packages/core/src/pattern/parser.ts:86

Parses a pattern(...) paint string into a structured Pattern object.

The grammar is pattern(<type>[, <foreground>[, <background>[, <size>]]]) where <type> is one of the built-in PATTERN_TYPES, <foreground>/<background> are CSS colors, and <size> is the square tile size in user-space pixels (an optional px suffix is accepted).

Parameters ​

ParameterTypeDescription
valuestringThe paint string to parse, e.g. pattern(diagonal, #1a6, #fff0, 8).

Returns ​

Pattern | null

The parsed pattern, or null when the string is not a valid pattern.