UNPKG

chromafx

Version:

CHROMAFX is a powerful and flexible terminal color and style management library. It offers a wide range of color options, including basic, bright, background, and 256-color palette support, as well as custom RGB colors. The package allows easy application

191 lines (177 loc) 5.39 kB
// index.js const colors = { // Basic colors black: "\x1b[30m", red: "\x1b[31m", green: "\x1b[32m", yellow: "\x1b[33m", blue: "\x1b[34m", magenta: "\x1b[35m", cyan: "\x1b[36m", white: "\x1b[37m", // Bright colors brightBlack: "\x1b[90m", brightRed: "\x1b[91m", brightGreen: "\x1b[92m", brightYellow: "\x1b[93m", brightBlue: "\x1b[94m", brightMagenta: "\x1b[95m", brightCyan: "\x1b[96m", brightWhite: "\x1b[97m", // Background colors bgBlack: "\x1b[40m", bgRed: "\x1b[41m", bgGreen: "\x1b[42m", bgYellow: "\x1b[43m", bgBlue: "\x1b[44m", bgMagenta: "\x1b[45m", bgCyan: "\x1b[46m", bgWhite: "\x1b[47m", // Bright background colors bgBrightBlack: "\x1b[100m", bgBrightRed: "\x1b[101m", bgBrightGreen: "\x1b[102m", bgBrightYellow: "\x1b[103m", bgBrightBlue: "\x1b[104m", bgBrightMagenta: "\x1b[105m", bgBrightCyan: "\x1b[106m", bgBrightWhite: "\x1b[107m", // Extended 256-color palette orange: "\x1b[38;5;208m", pink: "\x1b[38;5;213m", purple: "\x1b[38;5;141m", brown: "\x1b[38;5;94m", lightBlue: "\x1b[38;5;81m", lightGreen: "\x1b[38;5;120m", lightCyan: "\x1b[38;5;159m", lightRed: "\x1b[38;5;203m", lightMagenta: "\x1b[38;5;219m", lightYellow: "\x1b[38;5;229m", gray: "\x1b[38;5;245m", darkGray: "\x1b[38;5;236m", gold: "\x1b[38;5;220m", silver: "\x1b[38;5;247m", olive: "\x1b[38;5;100m", teal: "\x1b[38;5;37m", violet: "\x1b[38;5;177m", coral: "\x1b[38;5;209m", // New colors mint: "\x1b[38;5;121m", lavender: "\x1b[38;5;183m", peach: "\x1b[38;5;217m", turquoise: "\x1b[38;5;45m", navy: "\x1b[38;5;18m", mustard: "\x1b[38;5;221m", rose: "\x1b[38;5;218m", maroon: "\x1b[38;5;88m", beige: "\x1b[38;5;230m", skyBlue: "\x1b[38;5;117m", // Additional 40 colors aquamarine: "\x1b[38;5;86m", emerald: "\x1b[38;5;85m", sienna: "\x1b[38;5;130m", salmon: "\x1b[38;5;209m", plum: "\x1b[38;5;176m", navyBlue: "\x1b[38;5;17m", limeGreen: "\x1b[38;5;154m", indigo: "\x1b[38;5;55m", periwinkle: "\x1b[38;5;111m", chocolate: "\x1b[38;5;166m", crimson: "\x1b[38;5;197m", tomato: "\x1b[38;5;203m", orchid: "\x1b[38;5;170m", khaki: "\x1b[38;5;228m", mintCream: "\x1b[38;5;194m", slateGray: "\x1b[38;5;102m", seashell: "\x1b[38;5;254m", moccasin: "\x1b[38;5;223m", peru: "\x1b[38;5;137m", papayaWhip: "\x1b[38;5;230m", lightSalmon: "\x1b[38;5;216m", wheat: "\x1b[38;5;229m", royalBlue: "\x1b[38;5;63m", dodgerBlue: "\x1b[38;5;33m", mediumSeaGreen: "\x1b[38;5;78m", paleGreen: "\x1b[38;5;156m", coralRed: "\x1b[38;5;203m", goldenrod: "\x1b[38;5;179m", lightCoral: "\x1b[38;5;210m", darkSalmon: "\x1b[38;5;174m", darkSeaGreen: "\x1b[38;5;108m", springGreen: "\x1b[38;5;48m", mediumSlateBlue: "\x1b[38;5;99m", lightSteelBlue: "\x1b[38;5;147m", royalPurple: "\x1b[38;5;135m", honeydew: "\x1b[38;5;195m", lawnGreen: "\x1b[38;5;118m", paleTurquoise: "\x1b[38;5;159m", steelBlue: "\x1b[38;5;67m", forestGreen: "\x1b[38;5;28m", deepPink: "\x1b[38;5;199m", // Corresponding background colors bgAquamarine: "\x1b[48;5;86m", bgEmerald: "\x1b[48;5;85m", bgSienna: "\x1b[48;5;130m", bgSalmon: "\x1b[48;5;209m", bgPlum: "\x1b[48;5;176m", bgNavyBlue: "\x1b[48;5;17m", bgLimeGreen: "\x1b[48;5;154m", bgIndigo: "\x1b[48;5;55m", bgPeriwinkle: "\x1b[48;5;111m", bgChocolate: "\x1b[48;5;166m", bgCrimson: "\x1b[48;5;197m", bgTomato: "\x1b[48;5;203m", bgOrchid: "\x1b[48;5;170m", bgKhaki: "\x1b[48;5;228m", bgMintCream: "\x1b[48;5;194m", bgSlateGray: "\x1b[48;5;102m", bgSeashell: "\x1b[48;5;254m", bgMoccasin: "\x1b[48;5;223m", bgPeru: "\x1b[48;5;137m", bgPapayaWhip: "\x1b[48;5;230m", bgLightSalmon: "\x1b[48;5;216m", bgWheat: "\x1b[48;5;229m", bgRoyalBlue: "\x1b[48;5;63m", bgDodgerBlue: "\x1b[48;5;33m", bgMediumSeaGreen: "\x1b[48;5;78m", bgPaleGreen: "\x1b[48;5;156m", bgCoralRed: "\x1b[48;5;203m", bgGoldenrod: "\x1b[48;5;179m", bgLightCoral: "\x1b[48;5;210m", bgDarkSalmon: "\x1b[48;5;174m", bgDarkSeaGreen: "\x1b[48;5;108m", bgSpringGreen: "\x1b[48;5;48m", bgMediumSlateBlue: "\x1b[48;5;99m", bgLightSteelBlue: "\x1b[48;5;147m", bgRoyalPurple: "\x1b[48;5;135m", bgHoneydew: "\x1b[48;5;195m", bgLawnGreen: "\x1b[48;5;118m", bgPaleTurquoise: "\x1b[48;5;159m", bgSteelBlue: "\x1b[48;5;67m", bgForestGreen: "\x1b[48;5;28m", bgDeepPink: "\x1b[48;5;199m", // Font styles bold: "\x1b[1m", italic: "\x1b[3m", underline: "\x1b[4m", strikethrough: "\x1b[9m", inverse: "\x1b[7m", hidden: "\x1b[8m", normal: "\x1b[22m", // Normal weight (non-bold) doubleUnderline: "\x1b[21m", // Double underline (not universally supported) faint: "\x1b[2m", // Faint (dim) // Reset reset: "\x1b[0m", rgb: (r, g, b) => `\x1b[38;2;${r};${g};${b}m`, bgRgb: (r, g, b) => `\x1b[48;2;${r};${g};${b}m`, }; // Create an object with color and style functions const chromafx = {}; Object.keys(colors).forEach((key) => { if (key === 'rgb' || key === 'bgRgb') { chromafx[key] = colors[key]; } else if (key !== 'reset') { chromafx[key] = (text) => `${colors[key]}${text}${colors.reset}`; } }); module.exports = chromafx;