Skip to main content

A simple Python package to create, manipulate and mutate colors and color-scales.

Project description

littlecolors

PyPi Version License: MIT

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.

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

littlecolors-1.0.1.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

littlecolors-1.0.1-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file littlecolors-1.0.1.tar.gz.

File metadata

  • Download URL: littlecolors-1.0.1.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for littlecolors-1.0.1.tar.gz
Algorithm Hash digest
SHA256 8df40975d2ca79ba5ab69e7518f8d3264f0fd21d0aed52e50d0295d9ed8a925f
MD5 587a592adfe98ba4e17a2a5c0583679c
BLAKE2b-256 87f5e4e6efe7c4ffeaac40e280952889153d3d73698c5a8bb6631190d981571a

See more details on using hashes here.

File details

Details for the file littlecolors-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: littlecolors-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 21.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for littlecolors-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 40d157471820484a9da8e602fd6dde1383fca868f73f4871dae6f78ac8819a9b
MD5 14205d997f439a387c7c891d4985af21
BLAKE2b-256 1e374aff7f52444ca0e94ecf98d83670e3ff7b28e569b5ae5ed6a98ca21a7d86

See more details on using hashes here.

Supported by

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