Skip to main content

XXX

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.0.tar.gz (19.3 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.0-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: littlecolors-1.0.0.tar.gz
  • Upload date:
  • Size: 19.3 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.0.tar.gz
Algorithm Hash digest
SHA256 9adb9ceaec71371ee543597261049f1ad6544afce37536d633c5465688be0df5
MD5 c4e4e3ca1eb9f8bf6c58ac3de81afbc5
BLAKE2b-256 a76697733cd6acacefafb329b609cab0e07e1f9795a02e51328615f631617439

See more details on using hashes here.

File details

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

File metadata

  • Download URL: littlecolors-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 21.7 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 df309b6fe169ef7261070886f2bf99f222a42ed8023898962d21fa23dc89640d
MD5 f7539002b6f9ee8c61f5b7e886601a32
BLAKE2b-256 dd43080da3aa8ea26af31938d31cf0c6ca250058ee8bc5b4838d2896ce87e083

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