Skip to main content

A color library for CSS colors.

Project description

Donate via PayPal Discord Build Coverage Status PyPI Version PyPI - Python Version License

ColorAide

This is still a work in progress.

While ColorAide is very usable and out of the alpha stage, it is currently in a prerelease state. This simply means the API could still be in flux to some degree. ColorAide is still technically waiting for some issues related to CSS color syntax and behavior to be decided by the CSS Working Group.

Overview

ColorAide is a color library for Python with the intent to provide an easy to use interface to work with colors. While ColorAide is not just for CSS colors, there is a focus on supporting modern CSS color syntax as it is a format that is very commonly used. In addition to being able to parse almost all colors as specified in the CSS specification, ColorAide also supports a number of colors and formats for colors that are not in the CSS spec.

ColorAide is built on the idea of having a general color object in which you can easily manipulate a color, convert between colors in different spaces, and perform color related functions: interpolation, color distancing, color contrast, etc.

In the process of developing ColorAide, we also stumbled upon the JavaScript library Color.js which is created/maintained by the co-authors of some of the recent CSS color specifications. This project became heavily influenced by Color.js as it adopted a model we were already interested in. While our aim was not to port that library and be a 1:1 copy of it, it provided much clarity on the CSS specification and, in the end, left a clear impression on our API.

With ColorAide, you can specify a color, convert it to other color spaces, mix it with other colors, output it in different CSS formats, and much more!

>>> from coloraide import Color
>>> c = Color("red")
>>> c.to_string()
'rgb(255 0 0)'
>>> c.convert('hsl').to_string()
'hsl(0 100% 50%)'
>>> c.set("lch.chroma", 30).to_string()
'rgb(173.81 114.29 97.218)'
>>> Color("blue").mix("yellow", space="lch").to_string()
'rgb(255 65.751 107.47)'

Documentation

https://facelessuser.github.io/coloraide

License

MIT

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coloraide-0.11.0.tar.gz (4.5 MB view details)

Uploaded Source

Built Distribution

coloraide-0.11.0-py3-none-any.whl (96.7 kB view details)

Uploaded Python 3

File details

Details for the file coloraide-0.11.0.tar.gz.

File metadata

  • Download URL: coloraide-0.11.0.tar.gz
  • Upload date:
  • Size: 4.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12

File hashes

Hashes for coloraide-0.11.0.tar.gz
Algorithm Hash digest
SHA256 f73a1470f24adcb82e3438a4302be1554adb6041a970cf69032268d215e41575
MD5 0059c87a655ed14c0248449848016a00
BLAKE2b-256 22b6b8756f1c1d8dd8521a2bfbd540407d517eaa78d7a37ee8e0a6b8c9e84c8f

See more details on using hashes here.

File details

Details for the file coloraide-0.11.0-py3-none-any.whl.

File metadata

  • Download URL: coloraide-0.11.0-py3-none-any.whl
  • Upload date:
  • Size: 96.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12

File hashes

Hashes for coloraide-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4875f6d84a93ef573d04ffba9ed1c8fcc71f89a33fc78329e3ca4ec6e9eaa7b
MD5 3f3f7e7926938f2b79054372beedb7a8
BLAKE2b-256 91f1122cf13e4824b7c95414fb6ca5f700a66ebd588087b95445fc5d9312d918

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