Skip to content

Documentation / @ripl/terminal / resolveTerminalPaint

Function: resolveTerminalPaint() ​

resolveTerminalPaint(color, opacity?): TerminalColor | undefined

Defined in: terminal/src/color.ts:106

Resolves a CSS paint string and a context opacity into the color a pixel should be painted with.

The three-valued result is load-bearing: a paint the terminal cannot resolve still draws (in the terminal's default foreground), whereas one that resolves to nothing must draw no geometry at all.

Parameters ​

ParameterTypeDefault valueDescription
colorstringundefinedThe paint to resolve. Named colors, hex (including shorthand), rgb()/rgba(), hsl()/hsla(), hsv()/hsva(), gradients and patterns are all supported; a gradient or pattern resolves to its first non-transparent color, the closest single color a character cell can show.
opacitynumber1Additional alpha to composite over the paint's own, typically Context.opacity. Defaults to 1.

Returns ​

TerminalColor | undefined

The RGBA color to paint with; null when the paint is unresolvable (draw it, in the terminal's default foreground); or undefined when it resolves to nothing and must not be drawn at all (none, transparent, or zero effective alpha).