littlecolors
littlecolors is a simple Python package to create, manipulate and mutate colors and color-scales.
Installation and Usage
Install with pip:
pip install littlecolors
Here is a basic usage example:
# Imports
from littlecolors import Color, ColorGradient, ColorSegments
from littlecolors.preset import COLORS, COLORS_CSS, CMAPS
from littlecolors.helpers import show
# Colors
c1 = Color(0.65)
show(c1)
c2 = Color(120, 189, 56)
c2_light = c2.copy().update_lightness(+0.1)
show([c2, c2_light])
c3 = Color('#33cccc')
c4 = COLORS.MAGENTA()
c5 = 0.3 * COLORS.MAGENTA() + 0.7 * COLORS_CSS.REBECCAPURPLE()
# Colormaps
cmap1 = ColorGradient([c2, c2_light, c3, c4, c5])
show(cmap1)
colors_list: list[Color] = cmap1([0.1, 0.1, 0.25, 0.15, 0.89, 0.14])
cmap2 = ColorSegments([c2, c2_light, c3, c4, c5])
show(cmap2)
show(CMAPS.MATCH_RATIO())
show(CMAPS.RSA())
show(CMAPS.PLDDT())
# Compatibility with matplotlib or other packages
import numpy as np
import matplotlib.pyplot as plt
cmap = CMAPS.RedBlue()
cmap.set_values_range([-5, 5])
values_matrix = np.random.normal(0.0, 1.0, (20, 20))
colors_matrix = cmap(values_matrix)
plt.imshow(colors_matrix)
plt.show()
See a more complete usage example in the Notebook ./usage_example.ipynb.
Requirements
- Python 3.9 or later
- Python packages
numpy - Python package
matplotlib(optional, only to be able to display colors and color scales)
Credits
Some colors palette or colormaps are taken from the python packages Matplotlib and Seaborn.
Metadata
Release files for littlecolors 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| littlecolors-1.0.1.tar.gz | 19.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| littlecolors-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 41.2 kB
Release files / littlecolors-1.0.1.tar.gz
| Download URL | littlecolors-1.0.1.tar.gz |
|---|---|
| Size | 19.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8df40975d2ca79ba5ab69e7518f8d3264f0fd21d0aed52e50d0295d9ed8a925f
|
|
BLAKE2b-256 checksum How to use checksums |
87f5e4e6efe7c4ffeaac40e280952889153d3d73698c5a8bb6631190d981571a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.1
|
Release files / littlecolors-1.0.1-py3-none-any.whl
| Download URL | littlecolors-1.0.1-py3-none-any.whl |
|---|---|
| Size | 21.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
40d157471820484a9da8e602fd6dde1383fca868f73f4871dae6f78ac8819a9b
|
|
BLAKE2b-256 checksum How to use checksums |
1e374aff7f52444ca0e94ecf98d83670e3ff7b28e569b5ae5ed6a98ca21a7d86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.1
|