rgb

The rgb() function creates a 24-bit (true color) value from red, green, and blue channel values. Pass the result to color or backgroundColor in StyleOptions.

Signature

function rgb(r: number, g: number, b: number): RGBColorValue

Parameters

  • r: Red channel (0–255, clamped automatically).
  • g: Green channel (0–255, clamped automatically).
  • b: Blue channel (0–255, clamped automatically).

Return Value

Returns an RGBColorValue object: { __type: "rgb", r: number, g: number, b: number }

Usage

import { s, rgb } from "ts-better-console";

// Foreground color
console.log(s("Orange", { color: rgb(255, 136, 0) }));

// Background color
console.log(s("Neon", {
color: rgb(0, 255, 128),
backgroundColor: rgb(20, 20, 40),
}));

Want to support this project?

If you find ts-better-console useful and want to support its development, consider starring the GitHub repository or buying me a coffee! Your support helps me dedicate more time to improving the library and adding new features.

Want to contribute to this project?

Contributions are welcome! If you're interested in improving the library, fixing bugs, or adding new features, feel free to check out the GitHub repository and submit a pull request. Whether you're a seasoned developer or new to open source, your contributions can make a difference!