Painto
A flexible color library for Python with support for multiple color formats, arithmetic operations, and extensive color collections.
Quick Start
import painto
# Create colors from names, hex, or RGB values
red = painto.red
blue = painto.Color("#0000ff")
green = painto.Color(0, 255, 0)
# Basic color properties
print(red.hex) # "#ff0000"
print(red.rgb) # (255, 0, 0)
print(red.hsv) # (0.0, 1.0, 1.0)
# Color arithmetic
purple = red + blue
darker_red = red / 2
lighter_blue = blue * 2
# Generate color ranges
gradient = list(panto.color_range(red, blue, 5))
Key Features
- Multiple Input Formats: Names, hex strings, RGB/RGBA tuples
- Color Collections: W3C, XKCD
- Color Spaces: RGB, HSV, HSL, and grayscale conversion
- Console Output: ANSI color codes for terminal display
Basic Usage
Creating Colors
All color names from w3c/css, the XKCD color list, pride are available and searched in that order, so red (in all three lists) will return the w3c red unless another list is specifically requested.
# From color names
red = painto.red
blue = painto.blue
# From specific color spaces:
red = painto.xkcd.red # XKCD red is #e50000
# From hex strings
purple = painto.Color("#800080")
transparent_red = painto.Color("#ff000080") # With alpha
# From RGB values
green = painto.Color(0, 255, 0)
yellow = painto.Color(255, 255, 0, 128) # With alpha
# Random
new_color = painto.random_color()
new_w3c_color = painto.w3c.random()
new_colors = painto.xkcd.random(10) # will return a list of colors from the list
# For contrasting text, this returns black or white, depending on which is
# more contrasting, for use as text on a <color> background, for instance.
foreground = yellow.foreground # Will return black, for yellow
Color Properties
color = painto.orange
print(color.r, color.g, color.b, color.a) # 255 165 0 255
print(color.hex) # "#ffa500"
print(color.name) # "orange"
print(color.luminosity) # 0.696
print(color.hsv) # (0.108, 1.0, 255)
Color Operations
red = painto.red
blue = painto.blue
# Blend colors
purple = red + blue
# Scale brightness
darker = red / 2
lighter = blue * 2
Color Ranges
# Generate gradient between colors
colors = painto.color_range(Color("red"), Color("blue"), 10) # 10 steps
# Inclusive range (includes end color)
colors = painto.color_range(Color("red"), Color("blue"), 5, inclusive=True)
Console Output
color = painto.green
print(f"Here is some {color.console_string("Green text")}")
print(f"And some {color.console_string_bg("Green background with contrasting text")}")
Installation
pip install painto
Documentation
For more information, see the complete documentation
License
MIT License - see LICENSE file for details.
Metadata
Release files for painto 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| painto-0.3.0.tar.gz | 23.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| painto-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 46.3 kB
Release files / painto-0.3.0.tar.gz
| Download URL | painto-0.3.0.tar.gz |
|---|---|
| Size | 23.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
289dbfa003852e3c2dbb107ae511dfdbd1e1e8905630377d4d31b7f87ec0cac4
|
|
BLAKE2b-256 checksum How to use checksums |
659cbee459ccbce589539e53a5bff431c9082149bd7eedc92473611ee6460f30
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.4 CPython/3.12.6 Windows/11
|
Release files / painto-0.3.0-py3-none-any.whl
| Download URL | painto-0.3.0-py3-none-any.whl |
|---|---|
| Size | 23.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f47e65d0207471d923d751103c1328fe22f984da1362478ad7b5c7f527472863
|
|
BLAKE2b-256 checksum How to use checksums |
91965d1e0e7f76a3bf1c5872e5628f79b68ac190e27c898a9b16cdc5e4f30fe9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.4 CPython/3.12.6 Windows/11
|