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.0.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.0-py3-none-any.whl
(28.3 kB
view details)
File details
Details for the file coloray-0.1.0.tar.gz.
File metadata
- Download URL: coloray-0.1.0.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 |
b698a553fecf725800764a98f1d4dd6dffa2ca7bf037bf7185a7eb7620e8cf2f
|
|
| MD5 |
ca2eacae565a48e91d5678e50aea8bff
|
|
| BLAKE2b-256 |
bca8b548d16b96590f24f816ac608ab70f2a89b974e963040a4329c801c78109
|
File details
Details for the file coloray-0.1.0-py3-none-any.whl.
File metadata
- Download URL: coloray-0.1.0-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 |
13c1d3f1f5cf991402b98434da555de89ed4363ea4cf24b5874aefc43838ab44
|
|
| MD5 |
bd661f4a91f1259b062cc31bb20ca622
|
|
| BLAKE2b-256 |
660968eb52480448fa85d6a9bf0b24f8e90691599f03fafb33b54b5e9a3e8f9f
|