Documentation / @ripl/terminal / colorToAnsiFg
Function: colorToAnsiFg() ​
colorToAnsiFg(
color,opacity?):string|undefined
Defined in: terminal/src/color.ts:140
Converts a CSS color string to an ANSI truecolor foreground escape sequence. Resolution matches resolveTerminalPaint; alpha darkens the color toward black, there being no destination to composite a lone escape sequence against.
Parameters ​
| Parameter | Type | Default value | Description |
|---|---|---|---|
color | string | undefined | The paint to resolve. |
opacity | number | 1 | Additional alpha to composite over the paint's own. Defaults to 1. |
Returns ​
string | undefined
The escape sequence; '' when the paint is a color the terminal cannot resolve (draw it, but uncolored); or undefined when the paint resolves to nothing and must not be drawn at all.