MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / rainbowText

Function rainbowText

apps/kimi-code/src/tui/easter-eggs/dance.ts:52–68  ·  view source on GitHub ↗
(
  text: string,
  colors: readonly [string, ...string[]],
  offset = 0,
  bold = false,
)

Source from the content-addressed store, hash-verified

50
51/** Paint a string character-by-character through a palette, skipping spaces. */
52export function rainbowText(
53 text: string,
54 colors: readonly [string, ...string[]],
55 offset = 0,
56 bold = false,
57): string {
58 let colorIndex = offset;
59 return Array.from(text)
60 .map((char) => {
61 if (char === ' ') return char;
62 const color = colors[colorIndex % colors.length] ?? colors[0];
63 colorIndex++;
64 const style = chalk.hex(color);
65 return bold ? style.bold(char) : style(char);
66 })
67 .join('');
68}
69
70/** Read-only view of the dance state for components that only render it. */
71export interface RainbowDanceView {

Callers 3

dance.test.tsFile · 0.90
renderDanceWelcomeHeaderFunction · 0.85
renderDanceFooterModelFunction · 0.85

Calls 1

boldMethod · 0.80

Tested by

no test coverage detected