OKLCH color palette builder written in Python.
Project description
OKLCH_CSS_Palette_Builder
You can make OKLCH CSS palettes using this!
What is this?
This is a Python library which makes OKLCH CSS palettes. OKLCH is a perceptually uniform color space designed by Björn Ottosson in 2020 (you can read his blog). You can use it as CSS Color Module Level 4 with the most of modern browsers (check Can I Use...).
Although we can use OKLCH Color Picker & Converter, I think it is not easy to use because the surface of OKLCH is not flat. So I wrote this library for CSS developers.
Installation
pip install oklchcsspalette
How to use?
With Python >= 3.9, you can use this library as below.
from sys import argv
from oklchcsspalette import OklchCssPaletteBuilder
def main():
attributes = tuple(map(int, argv[1:7]))
ocpb = OklchCssPaletteBuilder(*attributes)
ocpb.make_css(argv[7])
if __name__ == "__main__":
main()
The attributes are int values needed to calcurate chromas on OKLCH space.
The argv[7] is a CSS file path. It must ends with ".css" (upper cases are ok).
Contrast ratio with srgb
For the web accessibility, the necessary minimum of the diffs of lightnesses are below.
- At least 3:1 (Level AA of large scale of text) -> 35
- At least 4.5:1 (Level AA of text or Level AAA of large scale of text) -> 45
- At least 7:1 (Level AAA of text) -> 55
I calculated these values on a gray scale (chroma = 0). I have not checked on other colors (chroma > 0), but I think I will get similar results.
With p3 and rec2020, a contrast ratio is not defined, but I think we can use these values.
License
Attention
- This library does not yield Tailwind CSS color names.
- This library outputs duplicated colors; black and white.
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 oklchcsspalette-1.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3872a1cafd403dbea178a801caaec159fce6e9a6289b28e0b87bcb2b569a4a07 |
|
MD5 | 0a7fc11bf04edd6cc632658d17996c55 |
|
BLAKE2b-256 | 6fc1417289905d65945d21114b0172dc819b99a94d5165c6d26f2c2f02a49454 |