A color library for CSS colors.
Project description
ColorAide
This is still a work in progress.
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
Built Distribution
Hashes for coloraide-0.1.0a25-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa982f0fc65468d46dc485078330b99b462c6850528203f83c5abd16e2a5ca47 |
|
MD5 | 41f6768df1c6cb96e7776946931cc212 |
|
BLAKE2b-256 | 5b3695771d34bb388a18582b74b5a0061f9afab2174a52e4d10cb447579e8d6b |