Skip to main content

Yet another Python color library.

Project description

colorzero is a color manipulation library for Python (yes, another one) which aims to be reasonably simple to use and “pythonic” in nature.

It does not aim to be as comprehensive, powerful, or that matter as correct as, say, colormath. colorzero originally grew out of work on my picamera project, hence it’s intended to be sufficiently simple that school children can use it without having to explain color spaces and illuminants. However, it does aim to be useful to a wide range of skills, hence it does include basic facilities for CIE Lab representations, and Delta-E calculations should you need them.

The major difference between colorzero and other libraries (grapefruit, colormath, etc.) is that its Color class is a namedtuple descendent. This means it is immutable; you cannot directly change the attributes of a Color instance. The major advantage of this is that instances can be used as keys in dictionaries (for simple LUTs), or placed in sets.

Manipulation of Color instances is done by typical operations with other classes the result of which is a new Color instance. For example:

>>> Color('red') + Color('blue')
<Color html='#ff00ff' rgb=(1, 0, 1)>
>>> Color('magenta') - Color('red')
<Color html='#0000ff' rgb=(0, 0, 1)>
>>> Color('red') - Red(0.5)
<Color html='#800000' rgb=(0.5, 0, 0)>
>>> Color('green') + Color('grey').red
<Color html='#808000' rgb=(0.501961, 0.501961, 0)>
>>> Color.from_hls(0.5, 0.5, 1.0)
<Color html='#00ffff' rgb=(0, 1, 1)>
>>> Color.from_hls(0.5, 0.5, 1.0) * Lightness(0.8)
<Color html='#00cccc' rgb=(0, 0.8, 0.8)>
>>> (Color.from_hls(0.5, 0.5, 1.0) * Lightness(0.8)).hls
HLS(h=0.5, l=0.4, s=1.0)

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

colorzero-1.1.tar.gz (25.2 kB view details)

Uploaded Source

Built Distribution

colorzero-1.1-py2.py3-none-any.whl (33.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file colorzero-1.1.tar.gz.

File metadata

  • Download URL: colorzero-1.1.tar.gz
  • Upload date:
  • Size: 25.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for colorzero-1.1.tar.gz
Algorithm Hash digest
SHA256 acba47119b5d8555680d3cda9afe6ccc5481385ccc3c00084dd973f7aa184599
MD5 7581c4b7fc5f52bf41422e4bbb29731a
BLAKE2b-256 080e826b882db4da2970f53331969d66efc2da2071ffd9a8824601d0feff513d

See more details on using hashes here.

File details

Details for the file colorzero-1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for colorzero-1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e3c36d15b293de2b2f77ff54a5bd243fffac941ed0a5332d0697a6612a26a0a3
MD5 53cee15f61534ccb208252ba2e45ceca
BLAKE2b-256 cca2718e78485d0a42c3c2971e0d4a0eb9878bd1121cd640f0773de0695c858e

See more details on using hashes here.

Supported by

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