Minimal Python library for colored terminal output
Project description
coloray
a minimal python library for colorful terminal output.
works with foreground colors, background colors, gradients, and text styles. works in 24-bit truecolor or 8-bit fallback mode.
features
- 24 bit support
- 8 bit fallback for older terminals
- gradients (foreground + background)
- background colors with optional foreground
- text styles: bold, italic, underline, strike, reverse
- easy to use, just like colorama but even better fr
install
pip install coloray
how to use
switching modes
you can pick between 24-bit truecolor and 8-bit colors:
from coloray import truecolor, ansi8bit
truecolor() # 24 bit mode
ansi8bit() # 8 bit mode
colors
from coloray import color
print(color.red + "red" + color.RESET)
print(color.orange + "orange" + color.RESET)
print(color.yellow + "yellow" + color.RESET)
print(color.lime + "lime" + color.RESET)
print(color.green + "green" + color.RESET)
print(color.cyan + "cyan" + color.RESET)
print(color.lightblue + "lightblue" + color.RESET)
print(color.blue + "blue" + color.RESET)
print(color.magenta + "magenta" + color.RESET)
print(color.black + "black" + color.RESET)
print(color.white + "white" + color.RESET)
print(color.RESET + "reset text" + color.RESET)
# hex and rgb colors
print(color.hex("#058aff") + "hex color" + color.RESET)
print(color.rgb(255,0,255) + "rgb color" + color.RESET)
text styles
from coloray import style
print(style.bold + "bold" + style.RESET)
print(style.italic + "italic" + style.RESET)
print(style.underline + "underline" + style.RESET)
print(style.strike + "strike" + style.RESET)
print(style.bold + style.underline + style.italic + "combined styles" + style.RESET)
background colors
# named backgrounds
print(color.bg.red + "bg red" + color.RESET)
print(color.bg.orange + "bg orange" + color.RESET)
print(color.bg.yellow + "bg yellow" + color.RESET)
# background + foreground
print(color.bg.white + color.black + "bg white with black text" + color.RESET + style.RESET)
# rgb / hex backgrounds
print(color.bg.rgb(128,0,128) + color.yellow + "bg purple with yellow text" + color.RESET + style.RESET)
print(color.bg.hex("#00ffff") + color.magenta + "bg cyan with magenta text" + color.RESET + style.RESET)
gradients
from coloray import color
# foreground gradient
print(color.gradient("#ff0000","#ff8800","gradient red->orange") + color.RESET)
print(color.gradient("#00ff00","#0000ff","gradient green->blue") + color.RESET)
print(color.gradient("#ff00ff","#00ffff","gradient magenta->cyan") + color.RESET)
# background gradient with optional foreground color
print(color.bg.gradient("#ff0000","#ff8800","gradient bg", fg=color.black) + style.RESET)
notes
- always use
color.RESETandstyle.RESETat the end to reset colors and styles. - gradients, hex, and rgb automatically adjust to 24 bit or 8 bit mode.
- background gradients can take a fixed
fgcolor to keep text readable. - all named colors are available for foreground and background (e.g.,
color.red,color.bg.red).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
coloray-0.1.1.tar.gz
(40.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
coloray-0.1.1-py3-none-any.whl
(28.3 kB
view details)
File details
Details for the file coloray-0.1.1.tar.gz.
File metadata
- Download URL: coloray-0.1.1.tar.gz
- Upload date:
- Size: 40.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a9409e5a021d61dc41b28dd70f2b3b223329ffea340d5cade4ce6ba7d107c7a
|
|
| MD5 |
3fb2030982884cefe446fdf2a5868982
|
|
| BLAKE2b-256 |
c6cf4170a3557529c2252268ab207f91b506b253df926dddda7a53496892c94c
|
File details
Details for the file coloray-0.1.1-py3-none-any.whl.
File metadata
- Download URL: coloray-0.1.1-py3-none-any.whl
- Upload date:
- Size: 28.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b64bafaac36f73bc1afdbe0d4ccfa76a05c067390e03e1b74f887c7637599ee
|
|
| MD5 |
36f48f53d6c70da462865a286158e5c7
|
|
| BLAKE2b-256 |
6ff6c4654298d0e6fd068a1a9f577655ee3b3d6d61c339f4a6f9381c7d97286c
|