Looks like a very useful little library. Although, have you looked at OpenColourIO and its Python bindings? It is the VFX industry standard for working with colour spaces, most companies will use OCIO for colour management throughout the process.
This looks really useful. I've played around with colormaps in a few visualization projects, but I've never made the time to learn about the various color packages.
Thanks! Colormath does an amazing job handling the mathematical conversions between color spaces, but has (at least to me) a somewhat verbose API. Spectra wraps that API in something simpler, and adds scales, ranges, blending, brightening/darkening, and saturation/desaturation.
Spectra uses grapefruit for parsing HTML names and hexcodes.
I'm most excited about the color scales. It looks like a helpful tool for situations where the standard colormaps in matplotlib/pyplot don't work well. Is that an appropriate use case?
I also like seeing nbviewer used for documentation, I haven't seen that very often.
Unrelated to the library itself: I dislike when python projects have an external website containing the docs, and have no docstrings in the code itself. Not only is the code harder to read, but it makes the inbuilt help() useless.
> And what is the parameter to brighten/darken/saturate/desaturate?
The parameter for brighten/darken is a positive/negative linear adjustment to the L(ightness) value of the color's Lab representation. (Spectra converts the color to Lab, makes the change, and then converts back to the original color space.)
Likewise, the parameter for saturate/desaturate is a positive/negative linear adjustment to the c(hroma) value of the color's Lch representation.
Another thanks for flagging, mark-r. I've updated spectra to address this issue more explicitly. Per colormath[0], colors are allowed to go out of gamut. Colors now have `mycolor.rgb` and `mycolor.rgb_clamped` properties; `mycolor.hexcode` uses the clamped values. Are there other ways you'd like to see the out-of-gamut issue addressed? Open to suggestions.