Skip to main content

OKLCH_CSS_Palette_Builder

PyPI - Python Version PyPI - Version CI Python package CodeQL codecov Code style: black GitHub repo size Codacy Badge

You can make OKLCH CSS palettes by 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

For Pip:

pip install oklchcsspalette

For Poetry:

poetry add 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

MIT License

Attention

  • This library does not yield Tailwind CSS color names.
  • This library outputs duplicated colors; black and white.

Metadata

Release files for oklchcsspalette 1.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for oklchcsspalette 1.2.3
File Size Uploaded Provenance Actions
oklchcsspalette-1.2.3.tar.gz 5.9 kB Without provenance Details for oklchcsspalette-1.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for oklchcsspalette 1.2.3
File Interpreter ABI Platform Actions
oklchcsspalette-1.2.3-py3-none-any.whl Python 3 none any Details for oklchcsspalette-1.2.3-py3-none-any.whl

Total release size: 13.2 kB

Release files / oklchcsspalette-1.2.3.tar.gz

Download URL oklchcsspalette-1.2.3.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
98c5d72a3dce2866442104cf38db625aff184ca288273f5124318503d3adb97d
BLAKE2b-256 checksum
How to use checksums
a4b254e92ad550424488bc9cbce4d92fbc4dc8b19455a499a0df61bb2352f47d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.10.12 Linux/5.15.90.1-microsoft-standard-WSL2

Release files / oklchcsspalette-1.2.3-py3-none-any.whl

Download URL oklchcsspalette-1.2.3-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f39debf0ae7357f92d6591bea6cc051524a48e9dac42564069fb205fda09b2cd
BLAKE2b-256 checksum
How to use checksums
0814f8c99cfd6c2d2a655c4b9bdc4bbb12891934e0226280ac8b3001dc391a3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.10.12 Linux/5.15.90.1-microsoft-standard-WSL2

Security for oklchcsspalette 1.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page