Skip to main content

Color strings for terminal ouput (ANSI 256 colors) using CSS-style ``rgb`` notation.

Project description

Color strings for terminal ouput (ANSI 256 colors) using CSS-style rgb notation.

Installation

pip install rgb2ansi

Usage

from rgb2ansi import color

print(color("Hello", fg='4444ff'), color("world!", bg='ff4400'))

You can pass a foreground (text) color, a background color, or both. The following inputs are accepted as color parameters:

  • Hex strings, e.g. ff4400.

  • Byte strings, e.g. b'\xff\x44\x00'

  • Sequences of integers, e.g. (255, 68, 0)

Note that color() is lossy: it simply rounds the color to the closest 8-bit color available.

License

BSD 3-clause.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rgb2ansi-1.0.0.tar.gz (1.8 kB view hashes)

Uploaded Source

Built Distribution

rgb2ansi-1.0.0-py2.py3-none-any.whl (3.3 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page