@briklab/lib/color
Color utilities with protection levels for parsing, formatting, and ANSI terminal output.
Color Manipulation
The Color class provides conversion between RGB, hex, and ANSI formats.
API
- Classes:
Color - Types:
ColorInput
Quick Start
ts
import { Color } from "@briklab/lib/color";
const color = new Color({ r: 255, g: 0, b: 0 }, "boundary");
console.log(color.hex()); // "#ff0000"
console.log(color.rgb()); // "rgb(255, 0, 0)"
console.log(color.ansiTruecolor()); // ANSI sequence for red foreground
console.log(color.wrapAnsi("Hello", { bold: true })); // Red bold "Hello"Features
- Multiple Formats: Convert between RGB, hex, and ANSI representations
- ANSI Support: Generate ANSI escape sequences for terminal coloring
- Text Wrapping: Easily wrap text with color and styling options
- Protection Levels: Control color output strictness
Diagram
Live Demo
Recommended to test it in your browser. The test here might not work properly
Console
No logs yet.
