MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / rgbAnsi

Function rgbAnsi

src/common/ansi-codes.ts:136–152  ·  view source on GitHub ↗
(color: string)

Source from the content-addressed store, hash-verified

134};
135
136function rgbAnsi(color: string): number[] {
137 const hexCode = (COLOR_PALETTE as Record<string, string | undefined>)[color];
138
139 if (hexCode === undefined) return [];
140
141 let rgb: number[] = [];
142 // Split the hex color strings with the format "#rrggbb" into an array of three hex numbers
143 let rgbArray = hexCode.match(/#([\da-f]{2})([\da-f]{2})([\da-f]{2})/i);
144 if (rgbArray !== null) {
145 rgb = rgbArray.slice(1).map((x) => parseInt(x, 16));
146 } else {
147 rgbArray = hexCode.match(/#([\da-f])([\da-f])([\da-f])/i);
148 rgb = rgbArray!.slice(1).map((x) => 16 * parseInt(x, 16));
149 }
150
151 return rgb;
152}
153
154export function ansiFgColor(
155 color: string | number,

Callers 2

ansiFgColorFunction · 0.85
ansiBgColorFunction · 0.85

Calls 3

matchMethod · 0.65
mapMethod · 0.65
sliceMethod · 0.65

Tested by

no test coverage detected